Re: awk(1) segfaults when building kernel modules

From: Ruslan Ermilov <ru_at_FreeBSD.org>
Date: Wed, 10 Aug 2011 21:11:53 +0000
On Wed, Aug 10, 2011 at 08:02:32PM +0000, Alexander Best wrote:
> On Wed Aug 10 11, Navdeep Parhar wrote:
> > On Wed, Aug 10, 2011 at 11:12 AM, Test Rat <ttsestt_at_gmail.com> wrote:
> > > `make -s buildkernel' seems to contain lots of segfaults after recent
> > > update of one-true-awk in r224731. It chokes on sys/conf/kmod_syms.awk.
> 
> just out of curiosity: what's the point of doing a vendor import during a
> beta phase? isn't this exactly the kind of stuff you DON'T want to do, because
> it can only turn out badly?

The previous version had a bug in handling the -v option
since the last import.  I sent a patch to bwk_at_ months ago,
but he only released the new version that included a fix
on August 7.

Unfortunately, while fixing another bug ("fixed day 1 bug
that resurrected deleted elements of ARGV when used as
filenames (in lib.c)."), not all code was fixed, and a NULL
pointer deference bug is triggered by the following code
snippet:

	awk 'BEGIN{delete ARGV[1]}{}' arg

%%%
Index: head/contrib/one-true-awk/lib.c
===================================================================
--- head/contrib/one-true-awk/lib.c	(revision 224760)
+++ head/contrib/one-true-awk/lib.c	(working copy)
_at__at_ -89,8 +89,13 _at__at_
 	char *p;
 
 	for (i = 1; i < *ARGC; i++) {
-		if (!isclvar(p = getargv(i))) {	/* find 1st real filename */
-			setsval(lookup("FILENAME", symtab), getargv(i));
+		p = getargv(i);	/* find 1st real filename */
+		if (p == NULL || *p == '\0') {	/* deleted or zapped */
+			argno++;
+			continue;
+		}
+		if (!isclvar(p)) {
+			setsval(lookup("FILENAME", symtab), p);
 			return;
 		}
 		setclvar(p);	/* a commandline assignment before filename */
%%%

> imho r224731 should completely be reverted. aren't those exactly the kind of
> commits re_at_ shouldn't approve?


-- 
Ruslan Ermilov
ru_at_FreeBSD.org
FreeBSD committer
Received on Wed Aug 10 2011 - 19:07:39 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:16 UTC