dlopen: support search path ending in /

When the search path is /usr/lib/, /usr/lib/foo.so fails to load because
there is no / after the search path. Fix this by requiring that either
the search path end with / or the following char is a /.
This commit is contained in:
Wim Taymans 2026-04-13 10:26:33 +02:00
parent 14b74962d6
commit 0cc3644e55
2 changed files with 2 additions and 2 deletions

View file

@ -265,7 +265,7 @@ static int load_ladspa_plugin(struct plugin *impl, const char *path, const char
if (len == 0 || len >= sizeof(filename))
continue;
if (strncmp(path, p, len) == 0 && path[len] == '/')
if (strncmp(path, p, len) == 0 && (path[len-1] == '/' || path[len] == '/'))
namelen = snprintf(filename, sizeof(filename), "%s", path);
else
namelen = snprintf(filename, sizeof(filename), "%.*s/%s.so", (int) len, p, path);

View file

@ -178,7 +178,7 @@ static inline int weakjack_load(struct weakjack *jack, const char *lib)
if (len == 0 || len >= sizeof(path))
continue;
if (strncmp(lib, p, len) == 0 && lib[len] == '/')
if (strncmp(lib, p, len) == 0 && (lib[len-1] == '/' || lib[len] == '/'))
pathlen = snprintf(path, sizeof(path), "%s", lib);
else
pathlen = snprintf(path, sizeof(path), "%.*s/%s", (int) len, p, lib);