summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-06-08 02:42:22 +0200
committerGravatar Matt Colyer2009-07-01 19:44:55 -0700
commit52d1beb6e43cc12ff57e648f1e5bdfadc4d36929 (patch)
tree2f125adbff707d23e24ab8b19f4c0f89abfab398
parentade4dedb5f0d69122a5c742aa96c8bd150dab9a7 (diff)
downloadlibimobiledevice-52d1beb6e43cc12ff57e648f1e5bdfadc4d36929.tar.gz
libimobiledevice-52d1beb6e43cc12ff57e648f1e5bdfadc4d36929.tar.bz2
lockdown: fix receive of large TLS-encapsulated plists
[#48 state:resolved] Signed-off-by: Matt Colyer <matt@colyer.name>
-rw-r--r--src/lockdown.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lockdown.c b/src/lockdown.c
index ae408be..a950ceb 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -211,23 +211,27 @@ iphone_error_t iphone_lckd_recv(iphone_lckd_client_t client, plist_t * plist)
}
}
datalen = ntohl(datalen);
+ log_dbg_msg(DBGMASK_LOCKDOWND, "%s: datalen = %d\n", __func__, datalen);
receive = (char *) malloc(sizeof(char) * datalen);
+ /* fill buffer and request more packets if needed */
if (!client->in_SSL) {
- /* fill buffer and request more packets if needed */
while ((received_bytes < datalen) && (ret == IPHONE_E_SUCCESS)) {
ret = usbmuxd_recv(client->sfd, receive + received_bytes, datalen - received_bytes, &bytes);
received_bytes += bytes;
}
} else {
- ssize_t res = gnutls_record_recv(*client->ssl_session, receive, datalen);
- if (res < 0) {
- log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_recv: Error occured: %s\n", gnutls_strerror(res));
- ret = IPHONE_E_SSL_ERROR;
- } else {
- received_bytes = res;
- ret = IPHONE_E_SUCCESS;
+ ssize_t res = 0;
+ while ((received_bytes < datalen) && (ret == IPHONE_E_SUCCESS)) {
+ res = gnutls_record_recv(*client->ssl_session, receive + received_bytes, datalen - received_bytes);
+ if (res < 0) {
+ log_dbg_msg(DBGMASK_LOCKDOWND, "gnutls_record_recv: Error occured: %s\n", gnutls_strerror(res));
+ ret = IPHONE_E_SSL_ERROR;
+ } else {
+ received_bytes += res;
+ ret = IPHONE_E_SUCCESS;
+ }
}
}