summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2015-11-17 01:51:26 +0100
committerGravatar Martin Szulecki2015-11-17 01:51:26 +0100
commitbe9da9f56d52cbb92170112d9105df9a101ac5d6 (patch)
tree498fced17c518c97980efd421d69038a15a5ede8
parent6070126868069f2ee01ea9414f4cfbe5de285267 (diff)
downloadlibimobiledevice-be9da9f56d52cbb92170112d9105df9a101ac5d6.tar.gz
libimobiledevice-be9da9f56d52cbb92170112d9105df9a101ac5d6.tar.bz2
Fix broken receive for regular receive method when using GnuTLS, toowork
-rw-r--r--src/idevice.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/idevice.c b/src/idevice.c
index b776e84..5550402 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -447,12 +447,20 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive(idevice_connecti
}
if (connection->ssl_data) {
+ uint32_t received = 0;
+ while (received < len) {
#ifdef HAVE_OPENSSL
- int received = SSL_read(connection->ssl_data->session, (void*)data, (int)len);
- debug_info("SSL_read %d, received %d", len, received);
+ int r = SSL_read(connection->ssl_data->session, (void*)((char*)(data+received)), (int)len-received);
#else
- ssize_t received = gnutls_record_recv(connection->ssl_data->session, (void*)data, (size_t)len);
+ ssize_t r = gnutls_record_recv(connection->ssl_data->session, (void*)(data+received), (size_t)len-received);
#endif
+ if (r > 0) {
+ received += r;
+ } else {
+ break;
+ }
+ }
+ debug_info("SSL_read %d, received %d", len, received);
if (received > 0) {
*recv_bytes = received;
return IDEVICE_E_SUCCESS;