summaryrefslogtreecommitdiffstats
path: root/src/lockdown.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-06-08 02:42:22 +0200
committerGravatar Martin Szulecki2009-06-08 10:41:43 +0200
commit38a37213ba6d5a2746cd7d5085d4d1587e7f8408 (patch)
tree09ce54fa32b37f76bc004bdad19b91ab2158f2b1 /src/lockdown.c
parent4ae6a292dfcbf7b67d54934c8782667e748b388d (diff)
downloadlibimobiledevice-38a37213ba6d5a2746cd7d5085d4d1587e7f8408.tar.gz
libimobiledevice-38a37213ba6d5a2746cd7d5085d4d1587e7f8408.tar.bz2
lockdown: fix receive of large TLS-encapsulated plists
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
Diffstat (limited to 'src/lockdown.c')
-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;
+ }
}
}