summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-15 19:45:51 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-15 19:45:51 +0000
commita97745c49c816d2aca93c0fe72cb6e3b624c8446 (patch)
tree8f46d31bb431c5f3257975d8553a32110137d4ed /usr.sbin
parent79c3cab0594e55b9ebaed093a5142fae23892171 (diff)
Accommodate POSIX basename(3) that takes a non-const parameter and
may modify the string buffer. ok florian@
Diffstat (limited to 'usr.sbin')
-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 */