public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libmudflap/24619]  New: mudflap instrumentation of dlopen is incorrect
@ 2005-11-01 17:45 debian-gcc at lists dot debian dot org
  2005-11-01 17:48 ` [Bug libmudflap/24619] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: debian-gcc at lists dot debian dot org @ 2005-11-01 17:45 UTC (permalink / raw)
  To: gcc-bugs

[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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-10  5:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-24619-4@http.gcc.gnu.org/bugzilla/>
2012-09-19 15:54 ` [Bug libmudflap/24619] mudflap instrumentation of dlopen is incorrect fche at redhat dot com
2013-11-10  5:54 ` pinskia at gcc dot gnu.org
2005-11-01 17:45 [Bug libmudflap/24619] New: " debian-gcc at lists dot debian dot org
2005-11-01 17:48 ` [Bug libmudflap/24619] " pinskia at gcc dot gnu dot org
2005-11-01 22:46 ` pinskia at gcc dot gnu dot org
2006-07-02 23:38 ` fche at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).