fetchmail-friends
[Top] [All Lists]

[fetchmail] Re: Incorrect headers (again, but this time with more debug info)

2003-05-21 02:27:58
Quoting from Frank A Ekern's mail on Wed, May 21, 2003 at 09:52:00AM +0200:
I tried your patch but I still have the same error. After inspecting the
code and using "everyones favorite debugging tool" (aka printf) I have
the following observations:
* The headers is fetched and readheaders returns PS_RETAINED, but the
error handling code in fetch_messages (driver.c) never sets
suppress_readbody, thus readbody will be called.
* The first time SockRead is called in readbody, -1 is returned and
fetchmail exits as no more data is available on the socket.

Please try this fresh patch then (undo the previous one):

=========================================================================
diff -Naur fetchmail-6.2.2.orig/transact.c fetchmail-6.2.2/transact.c
--- fetchmail-6.2.2.orig/transact.c     2003-05-20 13:12:10.000000000 +0530
+++ fetchmail-6.2.2/transact.c  2003-05-21 13:56:41.000000000 +0530
@@ -337,7 +337,8 @@
 /* shared by readheaders and readbody */
 static int sizeticker;
 
-#define EMPTYLINE(s)   ((s)[0] == '\r' && (s)[1] == '\n' && (s)[2] == '\0')
+#define EMPTYLINE(s)   (((s)[0] == '\r' && (s)[1] == '\n' && (s)[2] == '\0') \
+                       || ((s)[0] == '\n' && (s)[1] == '\0'))
 
 static int end_of_header (const char *s)
 /* accept "\r*\n" as EOH in order to be bulletproof against broken survers */
@@ -519,7 +520,10 @@
                if (outlevel > O_SILENT)
                    report(stdout,
                           GT_("incorrect header line found while scanning 
headers\n"));
+               if (outlevel >= O_VERBOSE)
+                   report (stdout, GT_("line: %s"), line);
                retain_mail = 1;
+               goto process_headers;
            }
 
            /* check for RFC822 continuations */
@@ -1308,9 +1312,7 @@
        /* check for end of message */
        if (protocol->delimited && *inbufp == '.')
        {
-           if (inbufp[1] == '\r' && inbufp[2] == '\n' && inbufp[3] == '\0')
-               break;
-           else if (inbufp[1] == '\n' && inbufp[2] == '\0')
+           if (EMPTYLINE(inbufp+1))
                break;
            else
                msgblk.msglen--;        /* subtract the size of the dot escape 
*/
=========================================================================

-- 
Sunil Shetye.