From root@gits.dyndns.org  Sun Jul  7 13:36:58 2002
Return-Path: <root@gits.dyndns.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F3A4F37B400
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  7 Jul 2002 13:36:57 -0700 (PDT)
Received: from smtp.noos.fr (camus.noos.net [212.198.2.70])
	by mx1.FreeBSD.org (Postfix) with ESMTP id EBC9843E9C
	for <FreeBSD-gnats-submit@freebsd.org>; Sun,  7 Jul 2002 13:36:52 -0700 (PDT)
	(envelope-from root@gits.dyndns.org)
Received: (qmail 37927277 invoked by uid 0); 7 Jul 2002 20:36:50 -0000
Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.229.153]) (envelope-sender <root@gits.dyndns.org>)
          by 212.198.2.70 (qmail-ldap-1.03) with SMTP
          for <FreeBSD-gnats-submit@freebsd.org>; 7 Jul 2002 20:36:50 -0000
Received: from gits.gits.dyndns.org (ptwqw61vdquelokb@localhost [127.0.0.1])
	by gits.gits.dyndns.org (8.12.5/8.12.4) with ESMTP id g67Kanr6080317
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 7 Jul 2002 22:36:50 +0200 (CEST)
	(envelope-from root@gits.dyndns.org)
Received: (from root@localhost)
	by gits.gits.dyndns.org (8.12.5/8.12.4/Submit) id g67KancY080316;
	Sun, 7 Jul 2002 22:36:49 +0200 (CEST)
	(envelope-from root)
Message-Id: <200207072036.g67KancY080316@gits.gits.dyndns.org>
Date: Sun, 7 Jul 2002 22:36:49 +0200 (CEST)
From: Cyrille Lefevre <cyrille.lefevre@laposte.net>
Reply-To: Cyrille Lefevre <cyrille.lefevre@laposte.net>
To: FreeBSD-gnats-submit@freebsd.org
Subject: mail is unable to parse From line w/o email address
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         40314
>Category:       bin
>Synopsis:       mail is unable to parse From line w/o email address
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    mikeh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jul 07 13:40:01 PDT 2002
>Closed-Date:    Wed Jan 08 21:10:53 PST 2003
>Last-Modified:  Wed Jan 08 21:10:53 PST 2003
>Originator:     Cyrille Lefevre
>Release:        FreeBSD 4.6-STABLE i386
>Organization:
ACME
>Environment:
System: FreeBSD gits 4.6-STABLE FreeBSD 4.6-STABLE #15: Sun Jun 23 06:31:23 CEST 2002 root@gits:/disk2/freebsd/src/sys/compile/CUSTOM i386

>Description:
	mail don't display messages w/ a badly formatted From line such as :
	From   Sun Jul  7 21:55:25 2002
	     ^ no email address
	the following patch try to parse the email address as a valid date
	before the decide that's really an email address.
>How-To-Repeat:
	cat << EOF > test.mbox
From   Sun Jul  7 21:55:25 2002
From: root@gits.dyndns.org
Date: Sun, 07 Jul 2002 21:55:24 +0200 (CEST)
To: test@gits.dyndns.org
Precedence: bulk

wrong body

EOF
	mail -f test.mbox
Mail version 8.1 6/6/93.  Type ? for help.
"test.mbox": 0 messages
& q
	# oops!
	cat << EOF >> test.mbox
From root@gits.dyndns.org Sun Jul  7 21:55:25 2002
From: root@gits.dyndns.org
Subject: right message
Date: Sun, 07 Jul 2002 21:55:24 +0200 (CEST)
To: test@gits.dyndns.org
Precedence: bulk

right body

EOF
	mail -f test.mbox
"test.mbox": 1 message 1 unread
>Fix:
Index: head.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/mail/head.c,v
retrieving revision 1.1.1.1.14.3
diff -u -r1.1.1.1.14.3 head.c
--- head.c	15 Mar 2002 19:46:31 -0000	1.1.1.1.14.3
+++ head.c	7 Jul 2002 20:20:30 -0000
@@ -113,12 +113,19 @@
 	 * Skip over "From" first.
 	 */
 	cp = nextword(cp, word);
-	cp = nextword(cp, word);
-	if (*word != '\0')
-		hl->l_from = copyin(word, &sp);
-	if (cp != NULL && cp[0] == 't' && cp[1] == 't' && cp[2] == 'y') {
+	/*
+	 * Illegal empty address.
+	 */
+	if (isdate(cp))
+		hl->l_from = copyin("nobody", &sp);
+	else {
 		cp = nextword(cp, word);
-		hl->l_tty = copyin(word, &sp);
+		if (*word != '\0')
+			hl->l_from = copyin(word, &sp);
+		if (cp != NULL && cp[0] == 't' && cp[1] == 't' && cp[2] == 'y') {
+			cp = nextword(cp, word);
+			hl->l_tty = copyin(word, &sp);
+		}
 	}
 	if (cp != NULL)
 		hl->l_date = copyin(cp, &sp);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mikeh 
Responsible-Changed-By: mikeh 
Responsible-Changed-When: Sun Jan 5 15:40:55 PST 2003 
Responsible-Changed-Why:  
I'll look at this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40314 
State-Changed-From-To: open->closed 
State-Changed-By: mikeh 
State-Changed-When: Wed Jan 8 21:10:14 PST 2003 
State-Changed-Why:  
Fixed in -current, MFC after 2 weeks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40314 
>Unformatted:
1 root@gits.dyndns.org  Sun Jul  7 21:55  10/211   "right message"
& d1
& q
"test.mbox" removed
	# oops!
