fetchmail-friends
[Top] [All Lists]

Re: [fetchmail]ssl socket close

2002-01-04 14:58:27
On Thu, Jan 03, 2002 at 01:50:57PM +0530, Sunil Shetye wrote:
I was testing the idle option for fetchmail. When the server
disconnected after half an hour, fetchmail went in an infinite loop.
ltrace showed that it was doing:

SSL_peek() = 0
ERR_get_error () = 0
SSL_read() = 0

in an infinite loop. This patch should fix the infinite loop:

        Eric, don't impliment this patch just yet.

============================================================================
diff -Naur fetchmail-5.9.6.orig/socket.c fetchmail-5.9.6/socket.c
--- fetchmail-5.9.6.orig/socket.c     Thu Nov  8 23:43:45 2001
+++ fetchmail-5.9.6/socket.c  Thu Jan  3 11:33:24 2002
@@ -581,7 +581,7 @@
                      newline = NULL;
              } else if ((newline = memchr(bp, '\n', n)) != NULL)
                      n = newline - bp + 1;
-             if ((n = SSL_read(ssl, bp, n)) == -1) {
+             if ((n = SSL_read(ssl, bp, n)) <= 0) {
                      return(-1);
              }
              /* Check for case where our single character turned out to
============================================================================

        I remember going over that stretch of code with a fine toothed
comb originally when it was still using SSLeay.  I also remember pulling
my hair out for days till I got it to work correctly under a variety
of conditions.

        It may have been a bug in the old code that is fixed in OpenSSL
now, but your fix might potentially cause some normal connections to
break.  There was a reason for it being the way it was back then and it
was related to some dain bramaged behavior related to the SSL_peek call
(which was known to be buggy).  That reason may no longer be valid, but
I want to test it out first in the environments where it originally went
break.

        I'll concede that the infinite loop is a problem.  But this
might not be the correct solution.

Sunil Shetye.

_______________________________________________
Fetchmail-friends mailing list
Fetchmail-friends(_at_)lists(_dot_)ccil(_dot_)org
http://lists.ccil.org/mailman/listinfo/fetchmail-friends

-- 
 Michael H. Warfield    |  (770) 985-6132   |  mhw(_at_)WittsEnd(_dot_)com
  /\/\|=mhw=|\/\/       |  (678) 463-0932   |  http://www.wittsend.com/mhw/
  NIC whois:  MHW9      |  An optimist believes we live in the best of all
 PGP Key: 0xDF1DD471    |  possible worlds.  A pessimist is sure of it!


<Prev in Thread] Current Thread [Next in Thread>