From 7012594926ee0bafc16d763f28f1bcb75a7b03fa Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 8 Apr 2026 12:00:04 +0200 Subject: [PATCH] dlopen: improve prefix check some more If we pass a path /usr/libevil/mycode.so, it might have a prefix of /usr/lib but we should still reject it. Do thi by checking that after the prefix match, we start a new directory. --- spa/plugins/filter-graph/plugin_ladspa.c | 4 ++-- src/modules/module-jack-tunnel/weakjack.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spa/plugins/filter-graph/plugin_ladspa.c b/spa/plugins/filter-graph/plugin_ladspa.c index 51167827b..6335d002f 100644 --- a/spa/plugins/filter-graph/plugin_ladspa.c +++ b/spa/plugins/filter-graph/plugin_ladspa.c @@ -262,10 +262,10 @@ static int load_ladspa_plugin(struct plugin *impl, const char *path, const char while ((p = split_walk(search_dirs, ":", &len, &state))) { int namelen; - if (len >= sizeof(filename)) + if (len == 0 || len >= sizeof(filename)) continue; - if (strncmp(path, p, len) == 0) + if (strncmp(path, p, len) == 0 && path[len] == '/') namelen = snprintf(filename, sizeof(filename), "%s", path); else namelen = snprintf(filename, sizeof(filename), "%.*s/%s.so", (int) len, p, path); diff --git a/src/modules/module-jack-tunnel/weakjack.h b/src/modules/module-jack-tunnel/weakjack.h index f5c6361ad..472adb253 100644 --- a/src/modules/module-jack-tunnel/weakjack.h +++ b/src/modules/module-jack-tunnel/weakjack.h @@ -175,10 +175,10 @@ static inline int weakjack_load(struct weakjack *jack, const char *lib) while ((p = pw_split_walk(search_dirs, ":", &len, &state))) { int pathlen; - if (len >= sizeof(path)) + if (len == 0 || len >= sizeof(path)) continue; - if (strncmp(lib, p, len) == 0) + if (strncmp(lib, p, len) == 0 && lib[len] == '/') pathlen = snprintf(path, sizeof(path), "%s", lib); else pathlen = snprintf(path, sizeof(path), "%.*s/%s", (int) len, p, lib);