SSL: Handle EOF case in ssl_get
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 11 Aug 2011 08:31:25 +0000 (10:31 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 11 Aug 2011 08:31:25 +0000 (10:31 +0200)
If gnutls was in use and gnutls_record_recv returned 0 (EOF)
the ssl_get function would never terminate.

src/tcpip.c

index b9466d6..c3a4b05 100644 (file)
@@ -1159,7 +1159,12 @@ int ssl_get(COMSTACK h, char **buf, int *bufsize)
 #if HAVE_GNUTLS_H
         res = gnutls_record_recv(sp->session, *buf + hasread,
                                  CS_TCPIP_BUFCHUNK);
-        if (res < 0)
+        if (res == 0)
+        {
+            TRC(fprintf(stderr, "gnutls_record_recv returned 0\n"));
+            return 0;
+        }
+        else if (res < 0)
         {
             if (ssl_check_error(h, sp, res))
                 break;