diff options
author | 2003-01-05 09:04:10 +0000 | |
---|---|---|
committer | 2003-01-05 09:04:10 +0000 | |
commit | 2402e912b746b3622abd133f209814f45c2ffc12 (patch) | |
tree | 5a7897e4af2c3a2b6547d979696240b0a216f862 | |
parent | bktr on macppc (diff) | |
download | wireguard-openbsd-2402e912b746b3622abd133f209814f45c2ffc12.tar.xz wireguard-openbsd-2402e912b746b3622abd133f209814f45c2ffc12.zip |
fix for PR3053 - NULL deref when fd == NULL in first dlsym() arg
ok miod drahn marc
-rw-r--r-- | gnu/usr.bin/ld/rtld/rtld.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gnu/usr.bin/ld/rtld/rtld.c b/gnu/usr.bin/ld/rtld/rtld.c index 08e095753f2..60525516de8 100644 --- a/gnu/usr.bin/ld/rtld/rtld.c +++ b/gnu/usr.bin/ld/rtld/rtld.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld.c,v 1.32 2002/12/11 23:24:39 millert Exp $ */ +/* $OpenBSD: rtld.c,v 1.33 2003/01/05 09:04:10 pvalchev Exp $ */ /* $NetBSD: rtld.c,v 1.43 1996/01/14 00:35:17 pk Exp $ */ /* * Copyright (c) 1993 Paul Kranenburg @@ -1529,15 +1529,17 @@ xprintf("dlclose(%s): refcount = %d\n", smp->som_path, LM_PRIVATE(smp)->spd_refc static void * __dlsym(void *fd, const char *sym) { - struct so_map *smp = (struct so_map *)fd, *src_map = NULL; + struct so_map *smp, *src_map = NULL; struct nzlist *np; long addr; /* * Restrict search to passed map if dlopen()ed. */ - if (LM_PRIVATE(smp)->spd_flags & RTLD_DL) - src_map = smp; + if (fd == NULL) + smp = link_map_head; + else + src_map = smp = (struct so_map *)fd; np = lookup(sym, &src_map, 1); if (np == NULL) { |