YAAB (Yet another awk bug) - Fix for '%*' bug

Arthur David Olson ado at elsie.UUCP
Fri Sep 20 05:52:36 AEST 1985


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 at seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks



More information about the Net.bugs mailing list