summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkurt <kurt@openbsd.org>2005-10-03 20:17:26 +0000
committerkurt <kurt@openbsd.org>2005-10-03 20:17:26 +0000
commiteefddc0cf0c306efcf74e452e8d4adc159e724de (patch)
treed5858ecd333c0eba5fc5477df3f0da67231da106
parentrefcount corrections: count common dep libs once and centralize dep lib (diff)
downloadwireguard-openbsd-eefddc0cf0c306efcf74e452e8d4adc159e724de.tar.xz
wireguard-openbsd-eefddc0cf0c306efcf74e452e8d4adc159e724de.zip
protect against errant programs that attempt to dlclose a handle that is
already closed (but still around due to refs).
-rw-r--r--libexec/ld.so/dlfcn.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libexec/ld.so/dlfcn.c b/libexec/ld.so/dlfcn.c
index 1e153e840df..6d63203fba8 100644
--- a/libexec/ld.so/dlfcn.c
+++ b/libexec/ld.so/dlfcn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dlfcn.c,v 1.59 2005/10/03 19:48:24 kurt Exp $ */
+/* $OpenBSD: dlfcn.c,v 1.60 2005/10/03 20:17:26 kurt Exp $ */
/*
* Copyright (c) 1998 Per Fogelstrom, Opsycon AB
@@ -277,6 +277,12 @@ _dl_real_close(void *handle)
elf_object_t *dynobj;
object = (elf_object_t *)handle;
+
+ if (object->opencount == 0) {
+ _dl_errno = DL_INVALID_HANDLE;
+ return (1);
+ }
+
dynobj = _dl_objects;
while (dynobj && dynobj != object)
dynobj = dynobj->next;