"mailx" screws up "reply" addresses in some cases

guy at sun.UUCP guy at sun.UUCP
Mon Oct 6 06:36:16 AEST 1986


For example, when you have a message such as:

	From homer at 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 at 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 at bu-cs.bu.edu
	Message-Id: <8610010057.AA16172 at 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 at 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 at sun.com (or guy at sun.arpa)



More information about the Net.bugs.usg mailing list