[comp.mail.sendmail] 5.61+SunOS4.0 barfs in returntosender

flynn@pixel.cps.msu.edu (Patrick J. Flynn) (03/16/89)

Hi. We have a Sun 4/280, OS4.0 running here. I wanted to install a
sendmail that uses the resolver but *doesn't* go through the YP-based
resolver code provided by Sun.  So I grabbed BIND 4.8 and built
libresolv, grabbed sendmail 5.61 and built sendmail using the
library.

Yesterday, I noticed a problem: barfmail messages weren't being sent by
this new sendmail.  Specifically, sendmail would segfault in
returntosender() (savemail.c), clobbering the MAILER-DAEMON message
that should have been sent.  Additionally, since the mailer segfaulted,
the mail queue was not cleaned out.  Both the original offending message
(i.e. the one that *caused* the MAILER-DAEMON message) and the queue
files that *would* have contained the MAILER-DAEMON message were left
behind.  Is everybody with me?  C'mon, keep up.

Anyway, after fooling around with dbx for a while, I discovered that
a register variable containing a pointer (`q' in returntosender)
was losing its value between 2 statements.  I didn't investigate
any further (probably a compiler error?); I changed the
` register ADDRESS *' declarations for p and q to `ADDRESS *'.

Then, the problem with `q' cleared up, but the routine still died
at the strcmp shown below.  In our .cf, the PostMasterCopy
field is empty.  Apparently strcmp() can't deal with one of the
strings being null, so I inserted a cheap check.
With this patch, sendmail barfmail works on our system.

Here is a context diff.  I don't know if one or both of these problems
are specific to SPARC/OS4.0, so don't apply the patch unless you have the
symptoms I noted above.

Cheers,
Pat Flynn

*** savemail.c	Wed Mar 15 11:02:15 1989
--- savemail.c.old	Thu Jan 26 10:51:01 1989
***************
*** 367,373 ****
  	extern ENVELOPE *newenvelope();
  	ENVELOPE errenvelope;
  	static int returndepth;
! 	ADDRESS *p, *q;
  	char *to, *cc;
  	int len;
  
--- 367,373 ----
  	extern ENVELOPE *newenvelope();
  	ENVELOPE errenvelope;
  	static int returndepth;
! 	register ADDRESS *p, *q;
  	char *to, *cc;
  	int len;
  
***************
*** 406,412 ****
  	to = buf;
  	for (q = returnq; q != NULL; q = q->q_next) {
  	    if (q->q_alias == NULL)
! 		if (PostMasterCopy && (strcmp(q->q_paddr, PostMasterCopy) == 0))
  		    cc = q->q_paddr;
  		else {
  		    /* Not Postmaster; already on the To: line? */
--- 406,412 ----
  	to = buf;
  	for (q = returnq; q != NULL; q = q->q_next) {
  	    if (q->q_alias == NULL)
! 		if (strcmp(q->q_paddr, PostMasterCopy) == 0)
  		    cc = q->q_paddr;
  		else {
  		    /* Not Postmaster; already on the To: line? */

--
Pat Flynn, CS, Mich. State U. | "What kind of chump do you take me for?" -Nick
flynn@cps.msu.edu             | "First Class!" -Rocky Rococo
(517) 353-4638                |