]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: uninitialized variable (2) (Coverity 1469898)
authorpaco <paco@voltanet.io>
Wed, 20 Jun 2018 16:25:28 +0000 (18:25 +0200)
committerpaco <paco@voltanet.io>
Fri, 22 Jun 2018 19:18:35 +0000 (21:18 +0200)
Previous correction (2c2d5cb397c140c05ad81e8c79273bd3af13b595) was not enough,
so now it is ensured that the argument shift is not negative nor zero.

Signed-off-by: F. Aragon <paco@voltanet.io>
lib/command.c

index a8e61c6bb4f1a8784ea2a441be104b1760c6deb9..0f38cdb83fad40ebafd4821b7915089bd63cfa5e 100644 (file)
@@ -261,8 +261,11 @@ void print_version(const char *progname)
 
 char *argv_concat(struct cmd_token **argv, int argc, int shift)
 {
-       int cnt = argc - shift;
-       const char *argstr[cnt];
+       int cnt = MAX(argc - shift, 0);
+       const char *argstr[cnt + 1];
+
+       if (!cnt)
+               return NULL;
 
        for (int i = 0; i < cnt; i++)
                argstr[i] = argv[i + shift]->arg;