Hi,

(proposed patch to maildrop/formatmbox.C attached)

This issue was reported to Debian BTS: http://bugs.debian.org/520344 on
Mar 2009 and I recently took part in its maintenance.

Problem:

The maildrop's log file generates funny line when "from:" exists in the DKIM
header content like in the attached example mailbox.txt.

You can reproduce this by running:
  /usr/bin/maildrop < mailbox.txt

This generate log entry as (space indented with | for readability):

|Date: Sun Jun 17 10:29:24 2012
|From: "Barnikow, Katja" <[email protected]>message-id:date:subject:con
|Subj: Test
|File: /var/mail/osamu                          

I checked this source and I think I found the bug :-)

This bug is in maildrop/formatmbox.C  where pointer skipping excess
whitespaces (but not banklines) at the start of line.

There is no need to do this since From: header always start at the first
character.  Continuation lines in header files have leading space.

Patch is for upstream 2.5.5 version.  

In old 2.0.3 source, this bug caused the From: header content to be
overwritten by the second match and not concatenated like now.  It is
probably because 2.0.3 version was not using "bufp->append(p, l);" but
making simple assignment in the last part of this function.

So this patch should fix to match only ^From: but if this header exist
twice, those contents are concatenated (without space).

Osamu

>From [email protected]
From: "Barnikow, Katja" <[email protected]>
To: "Ralf Hildebrandt" <[email protected]>
Subject: Test
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=charite.de; h=
        from:message-id:date:subject:content-type:mime-version
        :content-class:received:received:received:x-virus-scanned;s=
        default; t=1237383677; bh=7Q6qSv4vMWBVhAT79vzOdErsuTcjoLR3jOcVw/
        21upA=; b=IEVP0Ip6pwN8cG2vyAr7Gk2gaEmX7ZXrbKPbzGzip+GCcN9KihZOpo
        Ho49OItUmaGGCLeGudu+0rukZ95vSDFlvHqL5JBLU2NWuD/V9LS2lYl9upXDsnyp
        NNI6s7SWf8ZKjPdtPYDC2hc+iyk2AJQCk6XLmAl8QHR38ZuD5W2tI=

Body
--- formatmbox.C.orig	2012-06-17 14:42:59.176829893 +0900
+++ formatmbox.C	2012-06-17 14:50:50.135165248 +0900
@@ -85,7 +85,6 @@
 	const char *p=msglinebuf;
 	Buffer	*bufp=0;
 
-		while (*p != '\n' && isspace(*p))	p++;
 		if ( tolower(*p) == 'f' && tolower(p[1]) == 'r' &&
 			tolower(p[2]) == 'o' && tolower(p[3]) == 'm' &&
 			p[4] == ':')

Reply via email to