summaryrefslogtreecommitdiffstats
path: root/src/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2017-04-21 23:32:42 +0100
committerRoy Marples <roy@marples.name>2017-04-21 23:32:42 +0100
commit4342acad46a0a702ce1e33249dc7aa439e0e6da8 (patch)
treef843452b0dd76c489db350f9d14376bcf95ea67d /src/dhcpcd.c
parent91fabb156b69930d80e23391bd2606653340db08 (diff)
downloaddhcpcd-4342acad46a0a702ce1e33249dc7aa439e0e6da8.tar.xz
Should check that an interface name actually exists when
setting the pidfile.
Diffstat (limited to 'src/dhcpcd.c')
-rw-r--r--src/dhcpcd.c10
1 files changed, 6 insertions, 4 deletions
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, "", "", "");