From gil@limbic.ssdl.com  Fri Dec 29 21:59:05 1995
Received: from limbic.ssdl.com (limbic.ssdl.com [206.109.78.34])
          by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id VAA01427
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 29 Dec 1995 21:59:01 -0800 (PST)
Received: (from gil@localhost) by limbic.ssdl.com (8.7.2/8.7.2) id XAA22783; Fri, 29 Dec 1995 23:58:56 -0600 (CST)
Message-Id: <199512300558.XAA22783@limbic.ssdl.com>
Date: Fri, 29 Dec 1995 23:58:56 -0600 (CST)
From: "Gil Kloepfer Jr." <gil@limbic.ssdl.com>
Reply-To: gil@limbic.ssdl.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Bad From line handling in mail.local
X-Send-Pr-Version: 3.2

>Number:         922
>Category:       misc
>Synopsis:       From line handling incorrect in mail.local
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 29 22:00:01 PST 1995
>Closed-Date:    Sun Apr 12 11:19:02 PDT 1998
>Last-Modified:  Sun Apr 12 11:19:12 PDT 1998
>Originator:     Gil Kloepfer Jr.
>Release:        FreeBSD 2.0-BUILT-19950603 i386
>Organization:
SSDL
>Environment:

	Any FreeBSD environment using sendmail with mailers such as elm

>Description:

	If a "From " line is in the text of a message, a ">" is not
	consistently prepended to the word "From ", causing mailers such
	as elm to erroneously think that a new message has started.

	The problem occurs specifically when a "From " line occurs in the
	text of a message without a blank line before it.

	The problem has manifested itself more recently because I think
	the old local mailer in sendmail had the F=E option, and I know
	it doesn't now.  mail.local is the correct place to do the
	substitution, not sendmail.

>How-To-Repeat:

	Forward a message to yourself using elm, or remotely using any
	mail user agent that will not automatically prepend ">" to
	"From " lines.  The mail.local program will not do the proper
	prepending.

>Fix:

The logic for the original mail.local for handling "From " lines makes
little sense.  I have interpreted it as attempting to leave existing
"From " lines in the header alone, although I'm pretty sure that these
are supposed to have a prepended ">" also if there is a duplicate.  I
will leave it up to the sendmail people to interpret what the code should
have done, and what it should do now.

The bug is also in the current mail.local in the latest version of sendmail.
I have not checked the 2.1.0-RELEASE of FreeBSD to see if it exists there.

*** mail.local.c	Fri Dec 29 23:45:34 1995
--- mail.local.c.orig	Fri Dec 29 23:46:45 1995
***************
*** 158,171 ****
  	(void)fprintf(fp, "From %s %s", from, ctime(&tval));
  
  	line[0] = '\0';
! 	for (eline = 0; fgets(line, sizeof(line), stdin);) {
  		if (line[0] == '\n')
  			eline = 1;
! 		else
  			if (eline && line[0] == 'F' &&
  			    !memcmp(line, "From ", 5))
  				(void)putc('>', fp);
! 
  		(void)fprintf(fp, "%s", line);
  		if (ferror(fp)) {
  			e_to_sys(errno);
--- 158,172 ----
  	(void)fprintf(fp, "From %s %s", from, ctime(&tval));
  
  	line[0] = '\0';
! 	for (eline = 1; fgets(line, sizeof(line), stdin);) {
  		if (line[0] == '\n')
  			eline = 1;
! 		else {
  			if (eline && line[0] == 'F' &&
  			    !memcmp(line, "From ", 5))
  				(void)putc('>', fp);
! 			eline = 0;
! 		}
  		(void)fprintf(fp, "%s", line);
  		if (ferror(fp)) {
  			e_to_sys(errno);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: peter 
State-Changed-When: Mon Jan 1 04:30:15 PST 1996 
State-Changed-Why:  
This is actually intended behavior... 

The end-of-message marker is a blank line followed by "^From ".. 
ie: 
"nnFrom " 

So, if you have a message like this: (indented for example) 

foo bar baz 
From this I can see blah.. 

It should not be escaped because there is not a blank line. 

However: 

foo bar baz 

From this I can see blah... 

...should be escaped as the mail system cannot distinguish the end-of-msg. 

The actual bug is in pine and elm's mailbox decoding. 

Perhaps a 'bug compatable' flag for mail.local is needed? 
State-Changed-From-To: analyzed->closed 
State-Changed-By: phk 
State-Changed-When: Sun Apr 12 11:19:02 PDT 1998 
State-Changed-Why:  
timed out 
>Unformatted:
