<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -21,6 +21,7 @@
 #include &lt;ctype.h&gt;
 #include &lt;dirent.h&gt;
 #include &lt;errno.h&gt;
+#include &lt;libgen.h&gt;
 #include &lt;stdarg.h&gt;
 #include &lt;stddef.h&gt;
 #include &lt;stdio.h&gt;
@@ -794,7 +795,9 @@ static int conf_files_insert_sorted(stru
 	bool is_single = false;
 
 	if (name == NULL) {
-		name = basename(path);
+		char *pathc = strdup(path);
+		name = basename(pathc);
+		free(pathc);
 		is_single = true;
 	}
 
--- a/shared/util.c
+++ b/shared/util.c
@@ -22,6 +22,7 @@
 #include &lt;assert.h&gt;
 #include &lt;ctype.h&gt;
 #include &lt;errno.h&gt;
+#include &lt;libgen.h&gt;
 #include &lt;stdarg.h&gt;
 #include &lt;stddef.h&gt;
 #include &lt;stdio.h&gt;
@@ -173,8 +174,10 @@ char *modname_normalize(const char *modn
 char *path_to_modname(const char *path, char buf[static PATH_MAX], size_t *len)
 {
 	char *modname;
+	char *pathc = strdup(path);
 
-	modname = basename(path);
+	modname = basename(pathc);
+	free(pathc);
 	if (modname == NULL || modname[0] == '\0')
 		return NULL;
 
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -22,6 +22,7 @@
 #include &lt;dirent.h&gt;
 #include &lt;errno.h&gt;
 #include &lt;getopt.h&gt;
+#include &lt;libgen.h&gt;
 #include &lt;limits.h&gt;
 #include &lt;regex.h&gt;
 #include &lt;stdio.h&gt;
@@ -757,14 +758,17 @@ static int cfg_files_insert_sorted(struc
 	struct cfg_file **files, *f;
 	size_t i, n_files, namelen, dirlen;
 	void *tmp;
+	char *dirc;
 
 	dirlen = strlen(dir);
 	if (name != NULL)
 		namelen = strlen(name);
 	else {
-		name = basename(dir);
+		dirc = strdup(dir);
+		name = basename(dirc);
 		namelen = strlen(name);
 		dirlen -= namelen + 1;
+		free(dirc);
 	}
 
 	n_files = *p_n_files;
@@ -2613,7 +2617,7 @@ static int depmod_output(struct depmod *
 			int mode = 0644;
 			int fd;
 
-			snprintf(tmp, sizeof(tmp), "%s.%i.%li.%li", itr-&gt;name, getpid(),
+			snprintf(tmp, sizeof(tmp), "%s.%i.%" PRId64 ".%" PRId64, itr-&gt;name, getpid(),
 					tv.tv_usec, tv.tv_sec);
 			fd = openat(dfd, tmp, flags, mode);
 			if (fd &lt; 0) {
--- a/tools/kmod.c
+++ b/tools/kmod.c
@@ -22,6 +22,7 @@
 #include &lt;stdio.h&gt;
 #include &lt;stdlib.h&gt;
 #include &lt;string.h&gt;
+#include &lt;libgen.h&gt;
 
 #include &lt;shared/util.h&gt;
 
</pre></body></html>