🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.sys5
Article #646

bug in new version of awk (nawk)

#646
From: stevens
Date: Wed, 11 Nov 1987 19:52
53 lines
2167 bytes
Index:	awk/lib.c

Description:
	The new version of awk (available from the AT&T Toolchest -
	supposedly its also shipped with System 5.3.1) dumps core.
	If you don't pass enough arguments to awk's printf(), an error
	message is printed, with a copy of your format string that
	was in error.  When this format string reaches awk's error()
	function it is passed to fprintf().  However, since there are
	probably per-cent signs in your format argument to awk's printf,
	when awk's error() calls fprintf, it'll reference random memory
	locations through the stack trying to find the non-existent arguments.

Repeat-By:
	nawk '{printf("%s%s", "hi")}'       (then enter a return)

		This causes a core dump on a VAX running 4.3 BSD.
		Since the problem is random memory references through
		the stack, the symptoms will differ on other systems.
Fix:

*** /tmp/,RCSt1014068	Wed Nov 11 14:34:27 1987
--- /tmp/,RCSt2014068	Wed Nov 11 14:34:28 1987
***************
*** 442,452 ****
  	int f;
  	char *s;
  {
  	extern Node *curnode;
  	extern uchar *cmdname;
  
  	fprintf(stderr, "%s: ", cmdname);
! 	fprintf(stderr, s);
  	fprintf(stderr, "\n");
  	if (NR && *NR > 0) {
  		fprintf(stderr, " input record number %g", *FNR);
--- 442,457 ----
  	int f;
  	char *s;
  {
+ 	register int c;
  	extern Node *curnode;
  	extern uchar *cmdname;
  
  	fprintf(stderr, "%s: ", cmdname);
! #ifdef	notdef
! 	fprintf(stderr, s);	/* wont work if s contains any percents */
! #endif
! 	while (c = *s++)
! 		putc(c, stderr);
  	fprintf(stderr, "\n");
  	if (NR && *NR > 0) {
  		fprintf(stderr, " input record number %g", *FNR);
Technical Details
Message-ID: <716@hsi.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!sdcsvax!ucsdhub!esosun!seismo!uunet!hsi!stevens

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!sdcsvax!ucsdhub!esosun!seismo!uunet!hsi!stevens
From: stevens@hsi.UUCP
Newsgroups: comp.bugs.sys5
Subject: bug in new version of awk (nawk)
Message-ID: <716@hsi.UUCP>
Date: Wed, 11-Nov-87 14:52:14 EST
Article-I.D.: hsi.716
Posted: Wed Nov 11 14:52:14 1987
Date-Received: Sat, 14-Nov-87 15:10:17 EST
Organization: Health Systems Intl., New Haven, CT
Lines: 51
Keywords: awk, nawk