[net.news.adm] Minor fix for recmail

john@moncol.UUCP (John Ruschmeyer) (01/30/86)

Program: recmail.c (2.10.3 4.3 bsd beta)

Problem: The program incorrectly handles a line containing a cc: with no
         destinations in that it attemps to send a copy of the mail to
	 noone. Needless to say, this fails, leaving the user a copy of
	 his mail in dead.letter and a note from recmail.

Action:  Apply the following context diff:

*** recmail.c.orig	Wed Jan 29 02:06:22 1986
--- recmail.c	Wed Jan 29 22:47:27 1986
***************
*** 52,59
  			break;
  		if (strncmp(linebuf, "To: ", 4) == 0 ||
  		    strncmp(linebuf, "to: ", 4) == 0 ||
! 		    strncmp(linebuf, "TO: ", 4) == 0 ||
! 		    strncmp(linebuf, "Cc: ", 4) == 0 ||
  		    strncmp(linebuf, "cc: ", 4) == 0 ||
  		    strncmp(linebuf, "CC: ", 4) == 0)
  			addrecips(linebuf+4);

--- 52,60 -----
  			break;
  		if (strncmp(linebuf, "To: ", 4) == 0 ||
  		    strncmp(linebuf, "to: ", 4) == 0 ||
! 		    strncmp(linebuf, "TO: ", 4) == 0)
! 			addrecips(linebuf+4);
! 		else if (strncmp(linebuf, "Cc: ", 4) == 0 ||
  		    strncmp(linebuf, "cc: ", 4) == 0 ||
  		    strncmp(linebuf, "CC: ", 4) == 0)
  			if (linebuf[4] != '\n')
***************
*** 57,62
  		    strncmp(linebuf, "cc: ", 4) == 0 ||
  		    strncmp(linebuf, "CC: ", 4) == 0)
! 			addrecips(linebuf+4);
  	}
  	if (!feof(stdin)) {
  		while (fgets(linebuf, sizeof linebuf, stdin) != NULL) {

--- 58,64 -----
  		    strncmp(linebuf, "cc: ", 4) == 0 ||
  		    strncmp(linebuf, "CC: ", 4) == 0)
! 			if (linebuf[4] != '\n')
! 				addrecips(linebuf+4);
  	}
  	if (!feof(stdin)) {
  		while (fgets(linebuf, sizeof linebuf, stdin) != NULL) {



-- 
Name:		John Ruschmeyer
US Mail:	Monmouth College, W. Long Branch, NJ 07764
Phone:		(201) 571-3451
UUCP:		...!vax135!petsd!moncol!john	...!princeton!moncol!john
						   ...!pesnta!moncol!john

Give an ape control of its environment and it will fill the world with bananas.

brad@esc-bb.UUCP (Brad Benton) (02/21/86)

In article <158@moncol.UUCP> john@moncol.UUCP (John Ruschmeyer) writes:
>Program: recmail.c (2.10.3 4.3 bsd beta)
>
>Problem: The program incorrectly handles a line containing a cc: with no
>         destinations in that it attemps to send a copy of the mail to
>         noone. Needless to say, this fails, leaving the user a copy of
>         his mail in dead.letter and a note from recmail.
>
Further explication of the Problem:
    In addrecips (the routine that parses the To: and Cc: lines)
    it is possible to come up with a zero-length name by having
    trailing garbage (blanks, commas, etc.) in the line.  But
    addrecips doesn't notice this and goes ahead and collects a
    zero-length name for the mailer, which then is confronted with
    the user "" (in addition to all of the names validly parsed).  

Action:
    Also consider the following context diff.  The advantage of the
    following code is that with it, recmail will correctly handle all
    cases in which a zero-length recipient is parsed on any line that
    is passed to addrecips (both To: and Cc: lines).


*** recmail.c.orig	Thu Feb 20 08:33:07 1986
--- recmail.c	Thu Feb 20 22:43:40 1986
***************
*** 145,150
  	for (front=line; front < tail; ) {
  		while (!isok(*front) && front < tail)
  			front++;
  		for (back=front; isok(*back); back++)
  			;
  		*back=0;

--- 145,152 -----
  	for (front=line; front < tail; ) {
  		while (!isok(*front) && front < tail)
  			front++;
+ 		if (front >= tail)
+ 			break;		/* skip end-of-line garbage */
  		for (back=front; isok(*back); back++)
  			;
  		*back=0;


-- 

--brad benton
..!{gatech,seismo,ihnp4}!ut-sally!im4u!esc-bb!brad