[comp.bugs.4bsd] /usr/new/lam -P, multiple -p don't work per man page

eichin@athena.mit.edu (Mark W. Eichin) (05/13/88)

I found two bugs in /usr/new/lam. (The program, which I doubt you have
ever heard of (?) takes several files and laminates them together as
multiple columns of a single file.) This bug appears to apply to all
known versions.

Bug 1: The -P option does not stay in effect for the entire argument
list, as advertised.

Bug 2: When using -p or -f multiple consecutive times (to make up for
the lack of -P), lam will run off the end of the arg list in line 154
(sprintf(lp, ip->format, s);) because the format string values are
concatenated without intervening NUL's.

				Mark Eichin
			<eichin@athena.mit.edu>
		SIPB Member & Project Athena ``Watchmaker'' 

Version:
static char sccsid[] = "@(#)lam.c	4.4	(Berkeley)	4/5/86";

Patch:
*** /source/4.3/new/tools/src/lam.c	Sat Apr  5 03:41:02 1986
--- /tmp/lam.c	Fri May 13 02:56:23 1988
***************
*** 77,83 ****
  			if (!ip->sepstring)
  				ip->sepstring = (S ? (ip-1)->sepstring : "");
  			if (!ip->format)
! 				ip->format = (F ? (ip-1)->format : "%s");
  			if (!ip->eol)
  				ip->eol = (T ? (ip-1)->eol : '\n');
  			ip++;
--- 77,83 ----
  			if (!ip->sepstring)
  				ip->sepstring = (S ? (ip-1)->sepstring : "");
  			if (!ip->format)
! 				ip->format = ((P||F) ? (ip-1)->format : "%s");
  			if (!ip->eol)
  				ip->eol = (T ? (ip-1)->eol : '\n');
  			ip++;
***************
*** 105,111 ****
  		case 'f':
  			F = (*c == 'F' ? 1 : 0);
  			if (*++p || (p = *++av)) {
! 				fmtp += strlen(fmtp);
  				if (fmtp > fmtbuf + BUFSIZ)
  					error("No more format space", "");
  				sprintf(fmtp, "%%%ss", p);
--- 105,111 ----
  		case 'f':
  			F = (*c == 'F' ? 1 : 0);
  			if (*++p || (p = *++av)) {
! 				fmtp += strlen(fmtp)+1;
  				if (fmtp > fmtbuf + BUFSIZ)
  					error("No more format space", "");
  				sprintf(fmtp, "%%%ss", p);