Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site elsie.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!elsie!ado
From: ado@elsie.UUCP (Arthur David Olson)
Newsgroups: net.bugs
Subject: Re: YAAB (Yet another awk bug) - Fix for '%*' bug
Message-ID: <5221@elsie.UUCP>
Date: Thu, 19-Sep-85 15:52:36 EDT
Article-I.D.: elsie.5221
Posted: Thu Sep 19 15:52:36 1985
Date-Received: Sat, 21-Sep-85 04:05:35 EDT
References: <224@ur-cvsvax.UUCP> <2577@pegasus.UUCP> <3643@topaz.RUTGERS.EDU>
Organization: NIH-LEC, Bethesda, MD
Lines: 41
Summary: a more conservative fix

For fellow conservatives, here's a change to "run.c" that's:
	small in magnitude;
	gets rid of core dumps caused by '*' characters in awk format strings
	(and by excessively long format strings);
	and ensures that awk scripts that work on your system will be portable
	to other systems.
The disadvantage is that '*' characters in formats are not allowed--if one is
found, a fatal error message is produced.  See "substr" for workarounds.

As usual, the trade secret status of the code involved precludes a clearer
posting.

#ifdef OLDVERSION
		for (t=fmt; (*t++ = *s) != '\0'; s++)
			if (*s >= 'a' && *s <= 'z' && *s != 'l')
				break;
		*t = '\0';
		if (t >= fmt + sizeof(fmt))
			error(FATAL, "format item %.20s... too long", os);
#else
		for (t=fmt; (*t++ = *s) != '\0'; s++)
			if (t >= fmt + sizeof fmt)
				error(FATAL,
					"format item %.20s... too long", os);
			/*
			** Ought to use ctype, but that might change the
			** behavior on non-ASCII machines.
			*/
			else if (*s >= 'a' && *s <= 'z' && *s != 'l')
				break;
			else if (*s == '*')
				error(FATAL, "format item %s has wild '*'", os);
		*t = '\0';
#endif

--
Bugs is a Warner Brothers trademark.
Awk is a Polly the Parrot trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks