fix regression in dlsym: rejection of special RTLD_* handles as invalid
[musl] / src / ldso / dynlink.c
index 4ce1c3e..e73806c 100644 (file)
@@ -1091,7 +1091,7 @@ end:
        return p;
 }
 
-static int invalid_dso_handle(struct dso *h)
+static int invalid_dso_handle(void *h)
 {
        struct dso *p;
        for (p=head; p; p=p->next) if (h==p) return 0;
@@ -1119,7 +1119,8 @@ static void *do_dlsym(struct dso *p, const char *s, void *ra)
                        return __tls_get_addr((size_t []){def.dso->tls_id, def.sym->st_value});
                return def.dso->base + def.sym->st_value;
        }
-       if (invalid_dso_handle(p)) return 0;
+       if (p != RTLD_DEFAULT && p != RTLD_NEXT && invalid_dso_handle(p))
+               return 0;
        if (p->ghashtab) {
                gh = gnu_hash(s);
                sym = gnu_lookup(s, gh, p);
@@ -1246,7 +1247,7 @@ int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void
        return ret;
 }
 #else
-static int invalid_dso_handle(struct dso *h)
+static int invalid_dso_handle(void *h)
 {
        snprintf(errbuf, sizeof errbuf, "Invalid library handle %p", (void *)h);
        errflag = 1;