NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/41760: dlclose and dlsym do not always prepare dlerror when they fail
>Number: 41760
>Category: lib
>Synopsis: dlclose and dlsym do not always prepare dlerror when they fail
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 21 19:00:00 +0000 2009
>Originator: Taylor R Campbell <campbell%mumble.net@localhost>
>Release: NetBSD 5.0_STABLE
>Organization:
>Environment:
System: NetBSD joule.t.continuation.org 5.0_STABLE NetBSD 5.0_STABLE (RIAGATE)
#0: Sun Jun 14 17:49:06 EDT 2009
riastradh%Oberon.local@localhost:/Users/riastradh/os/netbsd/5/obj/sys/arch/i386/compile/RIAGATE
i386
Architecture: i386
Machine: i386
>Description:
If dlclose or dlsym fail, they should prepare dlerror to yield
appropriate error messages, but they do not always do so.
>How-To-Repeat:
Call dlclose or dlsym with a handle that is not known, such as
NULL. Observe that the call fails -- dlclose returns nonzero,
or dlsym returns NULL. Call dlerror to find the error string.
Read a stale error string or NULL.
Example: The following program should exit with value 2 and
print `dlclose: <message>', for some error message <message>.
Instead, it prints two messages to standard error, of which
one is from deep within ld.elf_so, and of which the other is
`dlclose gave no error message'; then it exits with value 1.
#include <err.h>
#include <dlfcn.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
if (dlclose(NULL) != 0)
{
const char *error = dlerror();
if (error == NULL)
errx(1, "dlclose gave no error message");
else
errx(2, "dlclose: %s", error);
}
errx(3, "dlclose succeeded");
}
>Fix:
Apply the following patch to src/libexec/ld.elf_so/rtld.c:
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/rtld.c,v
retrieving revision 1.124
diff -p -u -r1.124 rtld.c
--- rtld.c 19 May 2009 20:44:52 -0000 1.124
+++ rtld.c 21 Jul 2009 18:51:53 -0000
@@ -591,7 +591,7 @@ _rtld_dlcheck(void *handle)
break;
if (obj == NULL || obj->dl_refcount == 0) {
- xwarnx("Invalid shared object handle %p", handle);
+ _rtld_error("Invalid shared object handle %p", handle);
return NULL;
}
return obj;
>Unformatted:
Reply-To: riastradh
X-send-pr-version: 3.95
Home |
Main Index |
Thread Index |
Old Index