From: paco Date: Wed, 20 Jun 2018 16:25:28 +0000 (+0200) Subject: lib: uninitialized variable (2) (Coverity 1469898) X-Git-Tag: frr-6.1-dev~242^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a6a87d63d00902d3d17ac5e932c5b0a51d3b5bb2;p=matthieu%2Ffrr.git lib: uninitialized variable (2) (Coverity 1469898) 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 --- diff --git a/lib/command.c b/lib/command.c index a8e61c6bb4..0f38cdb83f 100644 --- a/lib/command.c +++ b/lib/command.c @@ -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;