Skip to content

Commit 48bdb88

Browse files
plugins: prevent crash with address-sanitizer when attempting to dlopen non-plugin libraries
1 parent 876a198 commit 48bdb88

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/plugins.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,13 @@ load_plugin (const char *plugdir, char *d_name, int l) {
880880
return -1;
881881
}
882882

883+
int has_lib_prefix = 0 == strncmp(d_name, "lib", min(3, strlen(d_name)));
884+
#ifndef ANDROID
885+
if (has_lib_prefix) {
886+
return -1;
887+
}
888+
#endif
889+
883890
trace ("loading plugin %s/%s\n", plugdir, d_name);
884891
void *handle = dlopen (fullname, RTLD_NOW);
885892
if (!handle) {
@@ -915,7 +922,7 @@ load_plugin (const char *plugdir, char *d_name, int l) {
915922
// don't error after failing to load plugins starting with "lib",
916923
// e.g. attempting to load a plugin from "libmp4ff.so",
917924
// except android, where all plugins have lib prefix
918-
if (android || strlen (d_name) < 3 || memcmp (d_name, "lib", 3)) {
925+
if (android || !has_lib_prefix) {
919926
trace ("dlsym error: %s (%s)\n", dlerror (), d_name + 3);
920927
return -1;
921928
}

0 commit comments

Comments
 (0)