diff options
author | Nikias Bassen | 2013-11-20 22:46:52 +0100 |
---|---|---|
committer | Nikias Bassen | 2013-11-20 22:46:52 +0100 |
commit | 184a9dc67badcc7d6638e685d9eb3a613d3b9c39 (patch) | |
tree | 562ebd6b1f144d38664bf289670b2a66dad1fd0e | |
parent | 7c19725dbe624d16a94ed05b80f47edb193c7fbf (diff) | |
download | libimobiledevice-184a9dc67badcc7d6638e685d9eb3a613d3b9c39.tar.gz libimobiledevice-184a9dc67badcc7d6638e685d9eb3a613d3b9c39.tar.bz2 |
idevice: properly handle partial SSL_read()s
-rw-r--r-- | src/idevice.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/idevice.c b/src/idevice.c index ec426e5..3ed2e9f 100644 --- a/src/idevice.c +++ b/src/idevice.c @@ -383,7 +383,15 @@ idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connecti if (connection->ssl_data) { #ifdef HAVE_OPENSSL - int received = SSL_read(connection->ssl_data->session, (void*)data, (int)len); + uint32_t received = 0; + while (received < len) { + int r = SSL_read(connection->ssl_data->session, (void*)((char*)(data+received)), (int)len-received); + if (r > 0) { + received += r; + } else { + break; + } + } debug_info("SSL_read %d, received %d", len, received); #else ssize_t received = gnutls_record_recv(connection->ssl_data->session, (void*)data, (size_t)len); |