fetchmail-friends
[Top] [All Lists]

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

2003-05-20 01:23:36
Quoting from Frank A Ekern's mail on Wed, May 14, 2003 at 08:02:46PM +0200:
RETR 1
+OK 2731 octets follow.
Return-Path: <deandreawilcox(_at_)bol(_dot_)com(_dot_)br>
Delivered-To: ekern-org-frank(_at_)ekern(_dot_)org
Received: (qmail 19067 invoked from network); 5 May 2003 12:54:38 -0000
Received: from unknown (HELO 210.51.176.146) (210.51.176.146)
  by ekern.org with SMTP; 5 May 2003 12:54:38 -0000
From: <deandreawilcox(_at_)bol(_dot_)com(_dot_)br>
To: <frank(_at_)ekern(_dot_)org>
Subject: - ALL OF THE ABOVE 
Content-Type: text/html;
      charset="windows-1251"
<html>

There is no delimiter line between headers and body. This is causing
the 'incorrect header' message.

color=#000000></DIV></FONT></TD></TR></TBODY></TABLE></TD></TR>
</html>
.

My guess is that your pop3 server is sending just '.\n' as the mail
delimiter line. fetchmail is currently searching only for '.\r\n'.
Thus, fetchmail is waiting for more data and eventually times out.
Please try the following patch:

=======================================================================
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-20 13:25:22.000000000 +0530
@@ -337,7 +337,7 @@
 /* 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 */
@@ -512,13 +512,15 @@
             * With it, we treat such messages as though they had the missing
             * blank line.
             */
-           if (!isspace(line[0]) && !strchr(line, ':'))
+           if (!retain_mail && !isspace(line[0]) && !strchr(line, ':'))
            {
                /* the headers_ok flag cannot be set to FALSE here as the
                 * delimiter has not occurred yet. */
                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;
            }
 
@@ -1308,9 +1310,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 
*/
=======================================================================

Note that this will still cause the mail to be retained. Whether such
mails should be retained or deleted automatically is a separate issue.
I think I will address it in a separate mail.

-- 
Sunil Shetye.