plugins: allow some absolute paths

Allow abosulte paths as long as they start with one of the search paths.
This commit is contained in:
Wim Taymans 2026-04-07 09:44:22 +02:00
parent 57299da899
commit 50aacea749
2 changed files with 17 additions and 9 deletions

View file

@ -170,18 +170,22 @@ static inline int weakjack_load(struct weakjack *jack, const char *lib)
search_dirs = PREFIX "/lib64/:" PREFIX "/lib/:"
"/usr/lib64/:/usr/lib/:" LIBDIR;
res = -ENAMETOOLONG;
while ((p = pw_split_walk(search_dirs, ":", &len, &state))) {
int pathlen;
if (len >= sizeof(path)) {
res = -ENAMETOOLONG;
if (len >= sizeof(path))
continue;
}
pathlen = snprintf(path, sizeof(path), "%.*s/%s", (int) len, p, lib);
if (pathlen < 0 || (size_t) pathlen >= sizeof(path)) {
res = -ENAMETOOLONG;
if (strncmp(lib, p, len) == 0)
pathlen = snprintf(path, sizeof(path), "%s", lib);
else
pathlen = snprintf(path, sizeof(path), "%.*s/%s", (int) len, p, lib);
if (pathlen < 0 || (size_t) pathlen >= sizeof(path))
continue;
}
if ((res = weakjack_load_by_path(jack, path)) == 0)
break;
}