Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: negative array indexing in disableshfuncnode



Coverity CID 46:

If you declare TRAPNOTHING(), then disable -f TRAPNOTHING,
this would try to set sigtrapped[-1].

Index: Src/hashtable.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/hashtable.c,v
retrieving revision 1.29
diff -u -r1.29 hashtable.c
--- Src/hashtable.c	11 Sep 2008 17:14:39 -0000	1.29
+++ Src/hashtable.c	1 Nov 2008 01:11:58 -0000
@@ -819,8 +819,10 @@
     hn->flags |= DISABLED;
     if (!strncmp(hn->nam, "TRAP", 4)) {
 	int signum = getsignum(hn->nam + 4);
-	sigtrapped[signum] &= ~ZSIG_FUNC;
-	unsettrap(signum);
+	if (signum != -1) {
+	    sigtrapped[signum] &= ~ZSIG_FUNC;
+	    unsettrap(signum);
+	}
     }
 }
 



Messages sorted by: Reverse Date, Date, Thread, Author