[net.bugs.usg] "mailx" screws up "reply" addresses in some cases

guy@sun.UUCP (10/05/86)

For example, when you have a message such as:

	From homer@bu-cs.bu.edu Tue Sep 30 20:58:11 1986
	Received: by bu-cs.bu.edu (5.31/4.7)
		id AA21517; Tue, 30 Sep 86 20:58:06 EDT
	Return-Path: <homer@bu-cs.bu.edu>
	Received: by bucse.bu.edu (5.31/4.7)
		id AA16172; Tue, 30 Sep 86 20:57:55 EDT
	Date: Tue, 30 Sep 86 20:57:55 EDT
	From: homer@bu-cs.bu.edu
	Message-Id: <8610010057.AA16172@bucse.bu.edu>
	To: ab, alpert, karenl, veress
	Subject: changes

	Text text text text text...

and try a "reply", it sends N copies to "veress@bu-cs.bu.edu".

The problem is that a static buffer is being used for the address, and it
isn't saving that static buffer before using it for the next address; since
it sticks a pointer to that address in the structure representing a name,
all the names end up being the last name stuffed into that buffer.

The fix, to "optim.c", is:

------- optim.c -------
*** /tmp/da0248	Sun Oct  5 13:36:02 1986
--- optim.c	Sat Oct  4 02:04:18 1986
***************
*** 239,245 ****
  	char from[];
  {
  	register char *cp;
! 	static char rbuf[200];
  
  	if (debug) fprintf(stderr, "makeremote(%s, %s) returns ", name, from);
  	strcpy(rbuf, name);
--- 239,245 ----
  	char from[];
  {
  	register char *cp;
! 	char rbuf[BUFSIZ];
  
  	if (debug) fprintf(stderr, "makeremote(%s, %s) returns ", name, from);
  	strcpy(rbuf, name);
***************
*** 248,254 ****
  		cp = rindex(from, '%');
  	strcat(rbuf, cp);
  	if (debug) fprintf(stderr, "%s\n", rbuf);
! 	return rbuf;
  }
  
  /*
--- 248,254 ----
  		cp = rindex(from, '%');
  	strcat(rbuf, cp);
  	if (debug) fprintf(stderr, "%s\n", rbuf);
! 	return(savestr(rbuf));
  }
  
  /*

which allocates a new string buffer for each recipient and returns a point
to it instead of a pointer to the local buffer.  Since the local buffer is
now purely temporary, it is made automatic.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com (or guy@sun.arpa)

levy@ttrdc.UUCP (Daniel R. Levy) (10/07/86)

In article <7926@sun.uucp>, guy@sun.UUCP writes:
>The fix, to "optim.c", is:
>
>------- optim.c -------
>*** /tmp/da0248	Sun Oct  5 13:36:02 1986
>--- optim.c	Sat Oct  4 02:04:18 1986
>***************
>*** 239,245 ****
>  	char from[];
>  {
>  	register char *cp;
>! 	static char rbuf[200];
>  
>  	if (debug) fprintf(stderr, "makeremote(%s, %s) returns ", name, from);
		  ^(void)

>  	strcpy(rbuf, name);
       ^(void)

>--- 239,245 ----
>  	char from[];
>  {
>  	register char *cp;
>! 	char rbuf[BUFSIZ];
>  
>  	if (debug) fprintf(stderr, "makeremote(%s, %s) returns ", name, from);
>  	strcpy(rbuf, name);
>***************
>*** 248,254 ****
>  		cp = rindex(from, '%');
>  	strcat(rbuf, cp);
       ^(void)

>  	if (debug) fprintf(stderr, "%s\n", rbuf);
                  ^(void)
>! 	return rbuf;
>  }
>  
>  /*
>--- 248,254 ----
>  		cp = rindex(from, '%');
>  	strcat(rbuf, cp);
>  	if (debug) fprintf(stderr, "%s\n", rbuf);
>! 	return(savestr(rbuf));
>  }
>  
>  /*
>which allocates a new string buffer for each recipient and returns a point
>to it instead of a pointer to the local buffer.  Since the local buffer is
>now purely temporary, it is made automatic.
>	Guy Harris

Hey, while you're making fixes to the "functionality" (love that non-word...)
why not make lint fixes too?
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
	   go for it!  			allegra,ulysses,vax135}!ttrdc!levy

guy@sun.uucp (Guy Harris) (10/09/86)

> Hey, while you're making fixes to the "functionality" (love that
> non-word...)

From "The Merriam-Webster Webster's Third New International Dictionary":

	func*tion*al*i*ty n -ES : the quality, state, or relation
	of being functional : UTILITY : INTERRELATION

So it's a word, although not meaning what computeroids use it to mean....

> why not make lint fixes too?

I did - about 10 tons of them - and posted them a long while ago.  After a
while, though, you reach the point of diminishing returns, and frankly I'd
gotten tired of throwing "(void)"s into somebody else's code.  I didn't see
much point in throwing them in in new code when they weren't there in the
existing code.

If you want to run all of "mailx" or "Mail" through "lint", be my guest....
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com (or guy@sun.arpa)