Accommodate a basename(3) that takes a non-const parameter and may
in fact modify the string buffer.
Between access(file, ...) and execl(file, ...), no check for
truncation should be necessary.
ok?
Index: usr.sbin/hotplugd/hotplugd.c
===================================================================
RCS file: /cvs/src/usr.sbin/hotplugd/hotplugd.c,v
retrieving revision 1.15
diff -u -p -r1.15 hotplugd.c
--- usr.sbin/hotplugd/hotplugd.c 30 Apr 2019 17:05:15 -0000 1.15
+++ usr.sbin/hotplugd/hotplugd.c 13 Oct 2020 16:19:43 -0000
@@ -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,
}
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 */
--
Christian "naddy" Weisgerber [email protected]