aboutsummaryrefslogtreecommitdiffstats
path: root/socket.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2002-02-15 03:52:22 +0000
committerEric S. Raymond <esr@thyrsus.com>2002-02-15 03:52:22 +0000
commita90b20cfb6fa5332dd8a4335b16a171feaf5a3a1 (patch)
treed6cb1a8bafd9b0ad735f27ada22a5c884be64cb5 /socket.c
parent0b3901aacf0dfb18d83570878919dbdbb7956709 (diff)
downloadfetchmail-a90b20cfb6fa5332dd8a4335b16a171feaf5a3a1.tar.gz
fetchmail-a90b20cfb6fa5332dd8a4335b16a171feaf5a3a1.tar.bz2
fetchmail-a90b20cfb6fa5332dd8a4335b16a171feaf5a3a1.zip
Minor fixes for 5.9.8.
svn path=/trunk/; revision=3578
Diffstat (limited to 'socket.c')
-rw-r--r--socket.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/socket.c b/socket.c
index 2631e1fb..ceadc960 100644
--- a/socket.c
+++ b/socket.c
@@ -563,13 +563,14 @@ int SockRead(int sock, char *buf, int len)
later change the behavior of SSL_peek
to "fix" this problem... :-( */
if ((n = SSL_peek(ssl, bp, len)) < 0) {
+ (void)SSL_get_error(ssl, n);
return(-1);
}
if( 0 == n ) {
/* SSL_peek says no data... Does he mean no data
or did the connection blow up? If we got an error
then bail! */
- if( 0 != ( n = ERR_get_error() ) ) {
+ if( 0 != ( n = SSL_get_error(ssl, n) ) ) {
return -1;
}
/* We didn't get an error so read at least one
@@ -581,8 +582,13 @@ int SockRead(int sock, char *buf, int len)
newline = NULL;
} else if ((newline = memchr(bp, '\n', n)) != NULL)
n = newline - bp + 1;
- if ((n = SSL_read(ssl, bp, n)) == -1) {
- return(-1);
+ /* Matthias Andree: SSL_read can return 0, in that case
+ * we must cal SSL_get_error to figure if there was
+ * an error or just a "no data" condition */
+ if ((n = SSL_read(ssl, bp, n)) <= 0) {
+ if ((n = SSL_get_error(ssl, n))) {
+ return(-1);
+ }
}
/* Check for case where our single character turned out to
* be a newline... (It wasn't going to get caught by
@@ -635,16 +641,20 @@ int SockPeek(int sock)
#ifdef SSL_ENABLE
if( NULL != ( ssl = SSLGetContext( sock ) ) ) {
n = SSL_peek(ssl, &ch, 1);
+ if (n < 0) {
+ (void)SSL_get_error(ssl, n);
+ return -1;
+ }
if( 0 == n ) {
/* This code really needs to implement a "hold back"
* to simulate a functioning SSL_peek()... sigh...
* Has to be coordinated with the read code above.
* Next on the list todo... */
- /* SSL_peek says no data... Does he mean no data
+ /* SSL_peek says 0... Does that mean no data
or did the connection blow up? If we got an error
then bail! */
- if( 0 != ( n = ERR_get_error() ) ) {
+ if( 0 != ( n = SSL_get_error(ssl, n) ) ) {
return -1;
}