Subject: pkg/30534: mini_sendmail messes up parsing some messages
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <wrstuden@netbsd.org>
List: pkgsrc-bugs
Date: 06/15/2005 19:13:00
>Number:         30534
>Category:       pkg
>Synopsis:       mini_sendmail messes up parsing some messages
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 15 19:13:00 +0000 2005
>Originator:     Bill Studenmund
>Release:        pkgsrc current
>Organization:
	
>Environment:
>Description:
	I noticed that occasionally I would send EMail and it would just
never appear anywhere. The account with the problem is the only account
I have that uses mini_sendmail.

After turning on debugging, I realized that some EMails work, and some
fail with an error 553. Upon further investigation, I found out
that the problem is mutt will wrap cc: recipients (and probably to:)
to extra lines if there are too many, and mini_sendmail's EMail parse
machine didn't work that right. Problem text looks like:

Cc: 'Torrey Morales' <billntorrey@covad.net>,
        'William Studenmund' <wrstuden@stanfordalumni.org>

mini_sendmail assumes everything fits in one line.
>How-To-Repeat:
1) Set mutt up to use mini_sendmail as its mail transport
2) Send a message with lots of cc: names
3) Watch EMail seem to send yet go nowhere.
>Fix:
The fix is to change mini_sendmail's state machine to handle the case
of a line feed right after a comma, so that it will keep looking on a
following line for recipients.

The following patch fixed mini_sendmail for me.

--- mini_sendmail.c.pkg	Wed Jun  8 23:19:01 2005
+++ mini_sendmail.c	Wed Jun  8 23:24:56 2005
@@ -366,6 +366,7 @@
 #define ST_BC		5
 #define ST_RECIPHEAD	6
 #define ST_RECIPS	7
+#define ST_RECIPMORE	8
     char* cp;
     char* bcc;
     char* recip;
@@ -489,9 +490,18 @@
 		}
 	    break;
 	    case ST_RECIPS:
+		/* FALLTHROUGH */
+	    case ST_RECIPMORE:
 	    switch ( *cp )
 		{
 		case '\n':
+		if ( cp == recip && state == ST_RECIPMORE )
+		    {
+		    /* Just parsed a ",\n", so ignore the \n */
+		    recip = cp + 1;
+		    state = ST_RECIPS;
+		    break;
+		    }
 		add_recipient( recip, ( cp - recip ) );
 		state = ST_BOL;
 		if ( bcc != (char*) 0 )

>Unformatted:
 		mini_sendmail-1.3.2nb3