diff options
| author | 2012-01-12 01:33:17 +0100 | |
|---|---|---|
| committer | 2012-01-12 01:33:17 +0100 | |
| commit | c182599c8c18ed729726ea7cbbd0a3b89790d2db (patch) | |
| tree | b1d5c257d1de1f67528cb8457aa766d0af6caad1 | |
| parent | be74df913206d354988db302eb049ed1e40a4a43 (diff) | |
| download | libimobiledevice-c182599c8c18ed729726ea7cbbd0a3b89790d2db.tar.gz libimobiledevice-c182599c8c18ed729726ea7cbbd0a3b89790d2db.tar.bz2 | |
idevice: add error checking to internal_ssl_write()
Returning 0 bytes sent upon error causes an infinite loop
within the calling gnutls code. Returning -1 as an error
code allows gnutls to properly detect and recover.
| -rw-r--r-- | src/idevice.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/idevice.c b/src/idevice.c index cad1431..af87e61 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -504,9 +504,13 @@ static ssize_t internal_ssl_read(gnutls_transport_ptr_t transport, char *buffer, | |||
| 504 | static ssize_t internal_ssl_write(gnutls_transport_ptr_t transport, char *buffer, size_t length) | 504 | static ssize_t internal_ssl_write(gnutls_transport_ptr_t transport, char *buffer, size_t length) |
| 505 | { | 505 | { |
| 506 | uint32_t bytes = 0; | 506 | uint32_t bytes = 0; |
| 507 | idevice_error_t res; | ||
| 507 | idevice_connection_t connection = (idevice_connection_t)transport; | 508 | idevice_connection_t connection = (idevice_connection_t)transport; |
| 508 | debug_info("pre-send length = %zi", length); | 509 | debug_info("pre-send length = %zi", length); |
| 509 | internal_connection_send(connection, buffer, length, &bytes); | 510 | if ((res = internal_connection_send(connection, buffer, length, &bytes)) != IDEVICE_E_SUCCESS) { |
| 511 | debug_info("ERROR: internal_connection_send returned %d", res); | ||
| 512 | return -1; | ||
| 513 | } | ||
| 510 | debug_info("post-send sent %i bytes", bytes); | 514 | debug_info("post-send sent %i bytes", bytes); |
| 511 | return bytes; | 515 | return bytes; |
| 512 | } | 516 | } |
