summaryrefslogtreecommitdiff
path: root/lib/command.c
diff options
context:
space:
mode:
authorpaco <paco@voltanet.io>2018-06-20 18:25:28 +0200
committerpaco <paco@voltanet.io>2018-06-22 21:18:35 +0200
commita6a87d63d00902d3d17ac5e932c5b0a51d3b5bb2 (patch)
treeb7601e444c0fb60c68418cacfd65ce2089d48fc5 /lib/command.c
parent2c2d5cb397c140c05ad81e8c79273bd3af13b595 (diff)
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 <paco@voltanet.io>
Diffstat (limited to 'lib/command.c')
-rw-r--r--lib/command.c7
1 files changed, 5 insertions, 2 deletions
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;