[net.bugs.4bsd] Sendmail aliases include extra CR without -DDBM

gnu@sun.uucp (John Gilmore) (12/12/84)

Bruce Keats' bug has been found and fixed.  Here's the fix.

Date: 21 Dec 83 16:37:15 PST (Wed)
From: gnu@sun.uucp (John Gilmore)
Subject: extra newlines in recipient addresses from alias file w/o DBM
Index: 	/usr/src/usr.lib/sendmail/src/alias.c 4.2BSD Fix

Description:
	When sendmail is compiled without DBM support for the alias file,
	each alias line is stored in the symbol table with an unexpected
	trailing newline.  This causes various problems, especially when
	the message is queued, since the newline causes a blank line in the
	saved "qf" file, which causes the message to be rejected next time
	the queue is run.

	This does not occur under DBM, because readalias() is never called
	with init==0 under DBM, and a different path thru the code is taken.

Repeat-By:
	Compile sendmail without DBM.
	Edit the following lines into /usr/lib/aliases:
		test12: user1, user2
	Execute: /usr/lib/sendmail -v -d27.9 test12
	The messages about "user1" will not have an extra newline.
	The messages about "user2" will have an extra newline after the '2'.

Fix:
	An off-by-1 error as usual.  The line is read with fgets, which
	keeps the newline at the end.  We zap it.

8c8
< SCCSID(@(#)alias.c 1.2 83/08/18 SMI (with DBM)); /* from UCB 3.47 4/17/83 */
---
> SCCSID(@(#)alias.c 1.3 83/12/21 SMI (with DBM)); /* from UCB 3.47 4/17/83 */
10c10
< SCCSID(@(#)alias.c 1.2 83/08/18 SMI (without DBM)); /* from UCB 3.47 4/17/83 */
---
> SCCSID(@(#)alias.c 1.3 83/12/21 SMI (without DBM)); /* from UCB 3.47 4/17/83 */
393,394c393,396
< 			else
< 				p = &p[strlen(p)];
---
> 			else {
> 				p = &p[strlen(p)-1];	/* Point to \n */
> 				*p = '\0';		/* Zap it */
> 			}