summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-08-04 00:12:47 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-08-04 00:12:47 +0000
commit20918a9bac024cd05083db0017c7ff284d6e6087 (patch)
tree91857d0cb97bbcabb052b93b6d065a298d5fdb00
parent8cd8ebd0c26e93b2236a4acce0664c86ce945a7b (diff)
downloadexecline-20918a9bac024cd05083db0017c7ff284d6e6087.tar.gz
execline-20918a9bac024cd05083db0017c7ff284d6e6087.tar.xz
execline-20918a9bac024cd05083db0017c7ff284d6e6087.zip
trap: fix off-by-one in argvs init
 Oh hey, gcc 10.2 actually came with a useful new warning that
helps catch off-by-ones!
-rw-r--r--src/execline/trap.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/execline/trap.c b/src/execline/trap.c
index 85a3116..9e5b4d2 100644
--- a/src/execline/trap.c
+++ b/src/execline/trap.c
@@ -20,7 +20,7 @@
 #define dieusage() strerr_dieusage(100, USAGE) ;
 
 static pid_t pids[SKALIBS_NSIG + 1] ;
-static char const *const *argvs[SKALIBS_NSIG] ;
+static char const *const *argvs[SKALIBS_NSIG] ; /* initted with 0s */
 
 static void action (unsigned int i, char const *const *envp)
 {
@@ -40,7 +40,7 @@ int main (int argc, char const **argv, char const *const *envp)
   tain_t tto ;
   int xfersigs = 0 ;
   int argc1, spfd ;
-  unsigned int i = SKALIBS_NSIG + 1 ;
+  unsigned int i = 0 ;
   PROG = "trap" ;
   {
     unsigned int t = 0 ;
@@ -67,8 +67,6 @@ int main (int argc, char const **argv, char const *const *envp)
   if (argc1 >= argc) strerr_dief1x(100, "unterminated block") ;
   if (argc1 + 1 == argc) dieusage() ;
   argv[argc1] = 0 ;
-  while (i--) argvs[i] = 0 ;
-  i = 0 ;
   tain_now_set_stopwatch_g() ;
   spfd = selfpipe_init() ;
   if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ;