summaryrefslogtreecommitdiff
path: root/libexec/ld.so/dlfcn.c
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2005-10-03 20:17:27 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2005-10-03 20:17:27 +0000
commit87ae4784db94f77bd54126580800d5756499c0bd (patch)
treecd0bac8c5f272531c0ebbe30d6ca6e83c03d2818 /libexec/ld.so/dlfcn.c
parentf0ec10f99ceed98f7aca872885d459d0b94f085b (diff)
protect against errant programs that attempt to dlclose a handle that is
already closed (but still around due to refs).
Diffstat (limited to 'libexec/ld.so/dlfcn.c')
-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;