summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-01-10 14:05:40 -0500
committerRich Felker <dalias@aerifal.cx>2013-01-10 14:05:40 -0500
commit6468fc9e37fd7a12c1406c03aa7c6b5e869d799b (patch)
treedd7885a437cb62d3bc8abb3ae1b4b999476f9b58 /src
parentd84923d89e4fe46877334cbaa5e4549f2c4cb8a6 (diff)
downloadmusl-6468fc9e37fd7a12c1406c03aa7c6b5e869d799b.tar.gz
musl-6468fc9e37fd7a12c1406c03aa7c6b5e869d799b.tar.bz2
musl-6468fc9e37fd7a12c1406c03aa7c6b5e869d799b.tar.xz
musl-6468fc9e37fd7a12c1406c03aa7c6b5e869d799b.zip
check for invalid handles in dlsym/dlclose
this is wasteful and useless from a standpoint of sane programs, but it is required by the standard, and the current requirements were upheld with the closure of Austin Group issue #639: http://austingroupbugs.net/view.php?id=639
Diffstat (limited to 'src')
-rw-r--r--src/ldso/dynlink.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 935367e3..782e979f 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -1091,6 +1091,15 @@ end:
return p;
}
+static int invalid_dso_handle(struct dso *h)
+{
+ struct dso *p;
+ for (p=head; p; p=p->next) if (h==p) return 0;
+ snprintf(errbuf, sizeof errbuf, "Invalid library handle %p", (void *)h);
+ errflag = 1;
+ return 1;
+}
+
static void *do_dlsym(struct dso *p, const char *s, void *ra)
{
size_t i;
@@ -1110,6 +1119,7 @@ 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->ghashtab) {
gh = gnu_hash(s);
sym = gnu_lookup(s, gh, p);
@@ -1236,6 +1246,12 @@ 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)
+{
+ snprintf(errbuf, sizeof errbuf, "Invalid library handle %p", (void *)h);
+ errflag = 1;
+ return 1;
+}
void *dlopen(const char *file, int mode)
{
return 0;
@@ -1259,5 +1275,5 @@ char *dlerror()
int dlclose(void *p)
{
- return 0;
+ return invalid_dso_handle(p);
}