Skip to content

Commit

Permalink
idevice: properly handle partial SSL_read()s
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Nov 20, 2013
1 parent 7c19725 commit 184a9dc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/idevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 184a9dc

Please sign in to comment.