From: Vincent Bernat Date: Fri, 22 Nov 2013 22:24:42 +0000 (+0100) Subject: coverity: handle case where we didn't get enough place in getopt string X-Git-Tag: 0.7.8~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3332985ad59887d5b26c4493a53fd607996bf55a;p=thirdparty%2Flldpd.git 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. --- 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) {