Commit b0cd07bf authored by myfreeweb's avatar myfreeweb

quirks: use basename in a POSIX compliant way

The POSIX version of basename modifies the string (and therefore crashes
on static strings), so use safe_strdup before calling it.

glibc provides a POSIX version when libgen.h is included.
FreeBSD 12 provides a POSIX version when nothing is included, which was
causing a segfault.

Using the POSIX version correctly is the right way to avoid any such issues.
parent 430ede82
Pipeline #5856 passed with stages
in 26 minutes and 14 seconds
......@@ -34,6 +34,7 @@
#include <libudev.h>
#include <dirent.h>
#include <fnmatch.h>
#include <libgen.h>
#include "libinput-versionsort.h"
#include "libinput-util.h"
......@@ -413,7 +414,9 @@ section_new(const char *path, const char *name)
struct section *s = zalloc(sizeof(*s));
xasprintf(&s->name, "%s (%s)", name, basename(path));
char *path_dup = safe_strdup(path);
xasprintf(&s->name, "%s (%s)", name, basename(path_dup));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment