From: Vincent Bernat Date: Sat, 9 May 2026 12:56:05 +0000 (+0200) Subject: client/lldpcli: guard argc>0 before indexing argv X-Git-Tag: 1.0.22~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fcc94a5c6aaa85dfda8ddd62baaf2abe219f1fb;p=thirdparty%2Flldpd.git client/lldpcli: guard argc>0 before indexing argv When the input is comment-only (e.g. "# foo"), tokenize_line() returns zero tokens; `argv[argc - 1]` then reads `argv[-1]`. Guard the access. Co-Authored-By: Claude Opus 4.7 (1M context) --- diff --git a/src/client/lldpcli.c b/src/client/lldpcli.c index 4286e024..2c4d3961 100644 --- a/src/client/lldpcli.c +++ b/src/client/lldpcli.c @@ -216,7 +216,7 @@ _cmd_complete(int all) char *compl = commands_complete(root, argc, (const char **)argv, all, is_privileged()); - if (compl &&strlen(argv[argc - 1]) < strlen(compl )) { + if (compl &&argc > 0 && strlen(argv[argc - 1]) < strlen(compl )) { if (rl_insert_text(compl +strlen(argv[argc - 1])) < 0) { free(compl ); goto end;