Runaway Sendmails

Charles Hedrick hedrick at topaz.RUTGERS.EDU
Sun Apr 13 15:26:30 AEST 1986


We have also seen runaway sendmails.  At least one cause is improper
error checking in the module collect.c.  Here are the things we have
found so far.  They may be other problems like these, though.

31a32
> 	extern char *RealHostName;  /* 2 host name in err msg */
76,77c77,80
< 	for (; !feof(InChannel); !feof(InChannel) && !ferror(InChannel) &&
< 				 sfgets(buf, MAXFIELD, InChannel) != NULL)
---
> /* 3 add ferror to termination condition to prevent infinite loop on error */
> 	for (; !feof(InChannel) && !ferror(InChannel);
> 	       !feof(InChannel) && !ferror(InChannel) &&
> 			 sfgets(buf, MAXFIELD, InChannel) != NULL)
85c88,90
< 			while ((c = getc(InChannel)) != '\n')
---
> /* 12 avoid infinite loop if error while in loop */
> 			while (((c = getc(InChannel)) != '\n') &&
> 			       (c != EOF))
135,136c140,143
< 	for (; !feof(InChannel); !feof(InChannel) && !ferror(InChannel) &&
< 				 sfgets(buf, sizeof buf, InChannel) != NULL)
---
> /* 3 add ferror to termination condition to prevent infinite loop on error */
> 	for (; !feof(InChannel) && !ferror(InChannel);
> 	       !feof(InChannel) && !ferror(InChannel) &&
> 	         sfgets(buf, sizeof buf, InChannel) != NULL)
165a173
> /* 2 add RealHostName to error message to help us track down problems */
167c175,179
< 		syserr("collect: unexpected close");
---
> 		syserr("collect: %s unexpected close",RealHostName);
> /* 3 add test for error and syserr if found - part of loop prevention */
> 	/* An error is always a bad sign */
> 	if (ferror(InChannel))
> 		syserr("collect: %s input error",RealHostName);



More information about the Comp.unix.wizards mailing list