diff options
author | 2020-10-15 19:45:50 +0000 | |
---|---|---|
committer | 2020-10-15 19:45:50 +0000 | |
commit | ca8229178b393753830bd5e012fbe89d3e81afaa (patch) | |
tree | 66ecdbc993412307964351c9beffc95820ab1888 | |
parent | Explicitly skip a leading "/dev/" and do not rely on basename(3) and (diff) | |
download | wireguard-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.c | 8 |
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 */ |