]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Should check that an interface name actually exists when
authorRoy Marples <roy@marples.name>
Fri, 21 Apr 2017 22:32:42 +0000 (23:32 +0100)
committerRoy Marples <roy@marples.name>
Fri, 21 Apr 2017 22:32:42 +0000 (23:32 +0100)
setting the pidfile.

src/dhcpcd.c

index 10583905bb3581a0d04bd5a6942bc02caed539fb..91b16e24d2e88c35ed3b6cfabcd1cc47059b93ea 100644 (file)
@@ -1603,10 +1603,12 @@ printpidfile:
                 *  instance for that interface. */
                if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) {
                        const char *per;
+                       const char *ifname;
 
-                       if (strlen(argv[optind]) > IF_NAMESIZE) {
-                               logerrx("%s: interface name too long",
-                                   argv[optind]);
+                       ifname = *ctx.ifv;
+                       if (ifname == NULL || strlen(ifname) > IF_NAMESIZE) {
+                               errno = ifname == NULL ? EINVAL : E2BIG;
+                               logerr("%s: ", ifname);
                                goto exit_failure;
                        }
                        /* Allow a dhcpcd interface per address family */
@@ -1621,7 +1623,7 @@ printpidfile:
                                per = "";
                        }
                        snprintf(ctx.pidfile, sizeof(ctx.pidfile),
-                           PIDFILE, "-", argv[optind], per);
+                           PIDFILE, "-", ifname, per);
                } else {
                        snprintf(ctx.pidfile, sizeof(ctx.pidfile),
                            PIDFILE, "", "", "");