summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaddy <naddy@openbsd.org>2020-10-15 19:45:50 +0000
committernaddy <naddy@openbsd.org>2020-10-15 19:45:50 +0000
commitca8229178b393753830bd5e012fbe89d3e81afaa (patch)
tree66ecdbc993412307964351c9beffc95820ab1888
parentExplicitly skip a leading "/dev/" and do not rely on basename(3) and (diff)
downloadwireguard-openbsd-ca8229178b393753830bd5e012fbe89d3e81afaa.tar.xz
wireguard-openbsd-ca8229178b393753830bd5e012fbe89d3e81afaa.zip
Accommodate POSIX basename(3) that takes a non-const parameter and
may modify the string buffer. ok florian@
-rw-r--r--usr.sbin/hotplugd/hotplugd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/hotplugd/hotplugd.c b/usr.sbin/hotplugd/hotplugd.c
index f532f24d51a..9239133c913 100644
--- a/usr.sbin/hotplugd/hotplugd.c
+++ b/usr.sbin/hotplugd/hotplugd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hotplugd.c,v 1.15 2019/04/30 17:05:15 mestre Exp $ */
+/* $OpenBSD: hotplugd.c,v 1.16 2020/10/15 19:45:50 naddy Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -28,6 +28,7 @@
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
+#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
@@ -163,7 +164,10 @@ exec_script(const char *file, int class, char *name)
}
if (pid == 0) {
/* child process */
- execl(file, basename(file), strclass, name, (char *)NULL);
+ char filebuf[PATH_MAX];
+
+ strlcpy(filebuf, file, sizeof(filebuf));
+ execl(file, basename(filebuf), strclass, name, (char *)NULL);
syslog(LOG_ERR, "execl %s: %m", file);
_exit(1);
/* NOTREACHED */