lmail patch

Jon Zeeff zeeff at b-tech.ann-arbor.mi.us
Tue Nov 8 00:36:04 AEST 1988


Here is a fix for lmail as it was posted to comp.sources.misc to allow
multiple names on an alias line.

From: umix!cs.buffalo.edu!kitty!gladys!rbdc!andy (Andy Pitts)

You are reading the lines from the alias file with a "%s %s" format 
string in a fscanf call.  This gets the name ok but will copy only the 
next field (separated with whitespace) into the variable line.  This 
works ok unless there is more than one alias or program name.  It will 
also not pass any arguments to a program and mess up the next call to 
fscanf if there is more than one alias.  

*** lmail.c.old	Wed Nov  2 04:47:30 1988
--- lmail.c	Wed Nov  2 04:51:09 1988
***************
*** 307,313
  		 * find a matching line in aliases
  		 */
  		rewind(aliases);
! 		while (fscanf(aliases, "%s %s", file, line) > 0) {
  			if (strcmp(file, table[i].dest) == 0)
  				break;
  		}

--- 307,316 -----
  		 * find a matching line in aliases
  		 */
  		rewind(aliases);
! 		/*
! 		 * fix fscanf to read rest of line into "line" AMP
! 		 */
! 		while (fscanf(aliases, "%s %[^\n]", file, line) > 0) {
  			if (strcmp(file, table[i].dest) == 0)
  				break;
  		}
***************
*** 313,318
  		}
  		if (!feof(aliases)) { 		/* we found one in aliases */
  			p = line;
  			(void) strcpy(owner, MAILMAN);
  		} else {
  			/*

--- 316,326 -----
  		}
  		if (!feof(aliases)) { 		/* we found one in aliases */
  			p = line;
+ 			/*
+ 			 * dump any leading white space AMP
+ 			 */
+ 			if(*p == ' ' || *p == '\t')
+ 				p++;
  			(void) strcpy(owner, MAILMAN);
  		} else {
  			/*


-- 
Jon Zeeff      			Ann Arbor, MI
umix!b-tech!zeeff  		zeeff at b-tech.ann-arbor.mi.us



More information about the Comp.sources.bugs mailing list