]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
coverity: handle case where we didn't get enough place in getopt string
authorVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 22:24:42 +0000 (23:24 +0100)
committerVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 22:24:42 +0000 (23:24 +0100)
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

index 2c143cd43b9457d3f0508ebd25cd9d8f52578fd2..7be728e453edad825f7bda672adfc5afb4464ecd 100644 (file)
@@ -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) {