Subject: bin/36532: fix for a core dump in /bin/sh dotrap()
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Greg A. Woods <woods@planix.com>
List: netbsd-bugs
Date: 06/23/2007 19:00:01
>Number:         36532
>Category:       bin
>Synopsis:       fix for a core dump in /bin/sh dotrap()
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 23 19:00:00 +0000 2007
>Originator:     Greg A. Woods
>Release:        netbsd-4 2007/06/22
>Organization:
Planix, Inc.; Toronto, Ontario; Canada
>Environment:
System: NetBSD 
>Description:

	there's a bug in dotrap() that can cause a core dump

>How-To-Repeat:
	
>Fix:

	this has been sitting in my local sources for a very long time
	and I recently discovered it still needed pulling up into my
	local netbsd-4 tree too

Index: bin/sh/trap.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/bin/sh/trap.c,v
retrieving revision 1.33
diff -u -r1.33 trap.c
--- bin/sh/trap.c	15 Jul 2005 17:23:48 -0000	1.33
+++ bin/sh/trap.c	10 Feb 2007 17:17:10 -0000
@@ -413,7 +413,19 @@
 		}
 		gotsig[i - 1] = 0;
 		savestatus=exitstatus;
-		evalstring(trap[i], 0);
+/*
+ * #3  0x00000001200162f8 in dotrap ()
+ *     at /building/work/woods/m-NetBSD-1.6/bin/sh/trap.c:398
+ * 398              evalstring(trap[i], 0);
+ * (gdb) print i
+ * $1 = 1
+ * (gdb) print trap[i]
+ * $2 = 0x0
+ */
+		if (trap[i])
+			evalstring(trap[i], 0);
+		else
+			error("got sig %d, but no trap command set!", i);
 		exitstatus=savestatus;
 	}
 done:

>Unformatted: