[Bug libmudflap/24619] New: mudflap instrumentation of dlopen is incorrect
debian-gcc at lists dot debian dot org
gcc-bugzilla@gcc.gnu.org
Tue Nov 1 17:45:00 GMT 2005
[forwarded from http://bugs.debian.org/336511]
bug submitter writes:
If mudflap is used to instrument a program using dlopen, and the program
(assuming it is compiled with -rdynamic) loads itself by passing NULL for the
path to dlopen, the program will crash unconditionally; that is, regardless of
the options passed to mudflap, so long as instrumentation is enabled.
This is because (at least with GNU/Linux) it is valid to pass a NULL pointer as
the path argument to dlopen, and the instrumentation code unconditionally uses
strlen on that pointer, without checking first if it is NULL.
I have included the following patch, which may help fix the problem. I have
not
tested it, but it should work. As always, it is "as is", with no warranty of
any kind. The patch is against svn HEAD (r104588).
- --- mf-hooks2.c.orig 2005-10-30 20:35:44.000000000 +0000
+++ mf-hooks2.c 2005-10-30 20:37:38.000000000 +0000
@@ -1679,8 +1679,10 @@ WRAPPER2(void *, dlopen, const char *pat
void *p;
size_t n;
TRACE ("%s\n", __PRETTY_FUNCTION__);
- - n = strlen (path);
- - MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "dlopen path");
+ if (NULL != path) {
+ n = strlen (path);
+ MF_VALIDATE_EXTENT (path, CLAMPADD(n, 1), __MF_CHECK_READ, "dlopen path");
+ }
p = dlopen (path, flags);
if (NULL != p) {
#ifdef MF_REGISTER_dlopen
--
Summary: mudflap instrumentation of dlopen is incorrect
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libmudflap
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24619
More information about the Gcc-bugs
mailing list