From nobody@FreeBSD.org  Thu Jan 19 06:23:00 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id ECE57106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 19 Jan 2012 06:23:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id D86C48FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 19 Jan 2012 06:23:00 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q0J6N0uM039603
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 19 Jan 2012 06:23:00 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q0J6N0b2039596;
	Thu, 19 Jan 2012 06:23:00 GMT
	(envelope-from nobody)
Message-Id: <201201190623.q0J6N0b2039596@red.freebsd.org>
Date: Thu, 19 Jan 2012 06:23:00 GMT
From: Stefan Schaeckeler <schaecsn@gmx.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mail expands aliases beyond #
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         164302
>Category:       bin
>Synopsis:       [patch] mail(1) expands aliases beyond #
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 19 06:30:11 UTC 2012
>Closed-Date:    
>Last-Modified:  Thu Jan 19 06:39:19 UTC 2012
>Originator:     Stefan Schaeckeler
>Release:        9.0
>Organization:
>Environment:
FreeBSD taipei 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Mon Jan 16 05:33:35 PST 2012     root@taipei:/usr/obj/usr/src/sys/TAIPEI  i386
>Description:
I'm not sure if this is a bug or a feature. For, me, it's a bug :) 

/usr/bin/mail parses ~/.mailrc and expands aliases in an unexpected way, e.g. for such an entry

--- snip ---
alias stefan   important@internet.com  # that's me
--- snip ---

/usr/bin/mail sends out email to 4 recipients:

1. important@internet.com
2. #
3. that's
4. me

I'm also using emacs/rmail which expands aliases from ~/.mailrc, but only up to the #. That's more intuitive.

>How-To-Repeat:

>Fix:
A fix could stop reading beyond # in usr.bin/mail/list.c:getrawlist(). See attachment.

Patch attached with submission follows:

--- list.c.orig	2012-01-19 06:04:25.000000000 -0800
+++ list.c	2012-01-19 05:47:29.000000000 -0800
@@ -393,7 +393,7 @@
 	for (;;) {
 		for (; *cp == ' ' || *cp == '\t'; cp++)
 			;
-		if (*cp == '\0')
+		if (*cp == '\0' || *cp == '#')
 			break;
 		if (argn >= argc - 1) {
 			printf(
@@ -402,7 +402,7 @@
 		}
 		cp2 = linebuf;
 		quotec = '\0';
-		while ((c = *cp) != '\0') {
+		while ((c = *cp) != '\0' && c != '#') {
 			/* Allocate more space if necessary */
 			if (cp2 - linebuf == linebufsize - 1) {
 				linebufsize += BUFSIZ;


>Release-Note:
>Audit-Trail:
>Unformatted:
