From 3332985ad59887d5b26c4493a53fd607996bf55a Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 22 Nov 2013 23:24:42 +0100 Subject: [PATCH] coverity: handle case where we didn't get enough place in getopt string While not currently possible, it may become possible in the future to forget to allocate enough place in getopt specification string to add protocols. --- src/daemon/lldpd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index 2c143cd4..7be728e4 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -1292,7 +1292,9 @@ lldpd_main(int argc, char *argv[], char *envp[]) * Get and parse command line options */ popt = strchr(opts, '@'); - for (i=0; protos[i].mode != 0; i++) + for (i=0; + protos[i].mode != 0 && popt && *popt != '\0'; + i++) *(popt++) = protos[i].arg; *popt = '\0'; while ((ch = getopt(argc, argv, opts)) != -1) { -- 2.39.5