From: Roy Marples Date: Fri, 21 Apr 2017 22:32:42 +0000 (+0100) Subject: Should check that an interface name actually exists when X-Git-Tag: v7.0.0-rc1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5f4db940c75d5c27cf9daa3e93ed077b67f653c;p=thirdparty%2Fdhcpcd.git Should check that an interface name actually exists when setting the pidfile. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 10583905..91b16e24 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -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, "", "", "");