[comp.bugs.4bsd] incorrect address rewriting during returntosender

e07@nikhefh.nikhef.nl (Eric Wassenaar) (08/27/90)

Ref:	All versions of sendmail up to/including 5.64

Description:
	Sendmail will rewrite 'new style' addresses in the header
	lines incorrectly when returning a message to the sender,
	e.g. when mailing back a return receipt or an error message.

Repeat-by:
	Send a message	To: him@hisdomain
	and ask for a	Return-Receipt-To: Your Name <you@yourdomain>

	Most probably (assuming his sendmail generates fully qualified
	addresses, and can handle 'old style' addresses) this appears
	in the return message as
	To: Your@hisdomain, Name@hisdomain, <you@yourdomain>

Analysis:
	Sendmail returns a message using the sequence
		sendtolist(recipient_list, ...)
		returntosender(...)
	The recipient(s) are parsed within sendtolist(), the 'new style'
	address is recognized, and the EF_OLDSTYLE bit is cleared in the
	envelope e_flags field.
	The actual delivery is done within returntosender(), but this
	routine switches to a temporary envelope which gets the default
	e_flags with the EF_OLDSTYLE bit set.
	During subsequent header rewriting, in putheader() and commaize(),
	the headers are handled incorrectly, with the above result.

Fix:
	In the routine returntosender() in the file savemail.c, after
	switching to the temporary envelope ee, add the following lines:

	if (!bitset(EF_OLDSTYLE, CurEnv->e_flags))
		ee->e_flags &= ~EF_OLDSTYLE;

Eric Wassenaar
-- 
Organization: NIKHEF-H, National Institute for Nuclear and High-Energy Physics
Address: Kruislaan 409, P.O. Box 41882, 1009 DB Amsterdam, the Netherlands
Phone: +31 20 592 0412, Home: +31 20 909449, Telefax: +31 20 592 5155
Internet: e07@nikhef.nl