Memory Leak In sendmail alias handling

Steven M. Schultz sms at wlv.imsd.contel.com
Sat Jul 22 14:06:15 AEST 1989


	There is a major memory leak in sendmail's building of
	the dbm alias database from /usr/lib/aliases.  Large numbers
	of aliases will cause sendmail to run out of memory, leaving
	partially constructed dbm files.

	The earlier fix i posted for this problem was incomplete (and
	partially incorrect), this patch corrects both problems.

	Apply the following patch to src/sendmail/alias.c and recompile
	sendmail.

*** alias.c.old	Wed Mar  8 14:54:25 1989
--- alias.c	Fri Jul 21 13:39:46 1989
***************
*** 453,459 ****
  						break;
  					if (parseaddr(p, &bl, -1, ',') == NULL)
  						usrerr("%s... bad address", p);
! 					free(bl);
  					p = DelimChar;
  				}
  			}
--- 453,460 ----
  						break;
  					if (parseaddr(p, &bl, -1, ',') == NULL)
  						usrerr("%s... bad address", p);
! 					if (bl.q_host && bl.q_host[0])
! 						free(bl.q_host);
  					p = DelimChar;
  				}
  			}
***************
*** 499,505 ****
  			content.dsize = rhssize;
  			content.dptr = rhs;
  			store(key, content);
! 			free(al);
  		}
  		else
  # endif DBM
--- 500,511 ----
  			content.dsize = rhssize;
  			content.dptr = rhs;
  			store(key, content);
! 			if (al.q_paddr)
! 				free(al.q_paddr);
! 			if (al.q_host)
! 				free(al.q_host);
! 			if (al.q_user)
! 				free(al.q_user);
  		}
  		else
  # endif DBM
======================================================================



More information about the Comp.bugs.2bsd mailing list