Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Jan 2012 21:54:12 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r230117 - head/bin/sh
Message-ID:  <201201142154.q0ELsCHg050397@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sat Jan 14 21:54:12 2012
New Revision: 230117
URL: http://svn.freebsd.org/changeset/base/230117

Log:
  sh: Fix out of bounds array access when trap is used with an invalid signal.
  
  MFC after:	1 week

Modified:
  head/bin/sh/trap.c

Modified: head/bin/sh/trap.c
==============================================================================
--- head/bin/sh/trap.c	Sat Jan 14 21:51:44 2012	(r230116)
+++ head/bin/sh/trap.c	Sat Jan 14 21:54:12 2012	(r230117)
@@ -191,10 +191,11 @@ trapcmd(int argc, char **argv)
 			argv++;
 		}
 	}
-	while (*argv) {
+	for (; *argv; argv++) {
 		if ((signo = sigstring_to_signum(*argv)) == -1) {
 			warning("bad signal %s", *argv);
 			errors = 1;
+			continue;
 		}
 		INTOFF;
 		if (action)
@@ -205,7 +206,6 @@ trapcmd(int argc, char **argv)
 		if (signo != 0)
 			setsignal(signo);
 		INTON;
-		argv++;
 	}
 	return errors;
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201142154.q0ELsCHg050397>