From a40508f4bb841bba5a1a33bb2d74cf8d8a68ba08 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 25 May 2013 17:49:29 -0400 Subject: [PATCH] Added more verbose messages for SSL read operations The ChangeLog erroneously states that: Fixed a bug which closed the application if there was a network problem in the WmnotifyGetResponse() function. --- ChangeLog | 5 +++++ src/imap.c | 5 +---- src/network.c | 24 ++++++++++++++++++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5c636ac..0168c93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ + +2005-09-27 Hugo Villeneuve + * Fixed a bug which closed the application if there was a network + problem in the WmnotifyGetResponse() function. + 2005-06-22 Hugo Villeneuve * Now using the same Tx and Rx buffers for POP3 and IMAP4. * Removed autogenerated files from subversion repository. diff --git a/src/imap.c b/src/imap.c index 3fc2e4f..bb80082 100644 --- a/src/imap.c +++ b/src/imap.c @@ -67,11 +67,8 @@ IMAP4_ReceiveResponse( void ) get_packet: len = WmnotifyGetResponse( rx_buffer, WMNOTIFY_BUFSIZE ); - if( len < 0 ) { - /* An error occured. */ - perror( PACKAGE ); - ErrorLocation( __FILE__, __LINE__ ); + /* An error occured. WmnotifyGetResponse() should have printed an error message. */ goto error; } else if( len == 0 ) { diff --git a/src/network.c b/src/network.c index caa1c28..c85ea4f 100644 --- a/src/network.c +++ b/src/network.c @@ -195,12 +195,28 @@ WmnotifyGetResponse( char *buffer, int max_size ) #if HAVE_SSL if( wmnotify_infos.use_ssl == TRUE ) { len = SSL_read( ssl_infos.ssl, buffer, max_size ); /* Get reply & decrypt */ - if( len <= 0 ) { - SSL_get_error( ssl_infos.ssl, len ); - len = -1; + switch( SSL_get_error( ssl_infos.ssl, len ) ) { + case SSL_ERROR_NONE: + /* Success. */ + break; + case SSL_ERROR_ZERO_RETURN: + fprintf( stderr, "%s: SSL_read() connection closed.\n", PACKAGE ); + break; + case SSL_ERROR_SYSCALL: + fprintf( stderr, "%s: SSL_read() I/O error.\n", PACKAGE ); + goto ssl_error; + case SSL_ERROR_SSL: + fprintf( stderr, "%s: SSL_read() protocol error.\n", PACKAGE ); + goto ssl_error; + default: + fprintf( stderr, "%s: SSL_read() error.\n", PACKAGE ); + goto ssl_error; } - + return len; + + ssl_error: + return -1; } #endif /* HAVE_SSL */ -- 2.20.1