bug-libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix more possible null derefs in libltdl


From: Ralf Wildenhues
Subject: fix more possible null derefs in libltdl
Date: Mon, 27 Sep 2004 19:42:52 +0200
User-agent: Mutt/1.4.1i

More null pointer fun.  

Regards,
Ralf

2004-09-27  Ralf Wildenhues <address@hidden>

        * libltdl/lt__alloc.c (lt__memdup), libltdl/ltdl.c
        (lt_dlcaller_register): Allocation can fail, so we
        need to guard against null pointer dereference here.


Index: libltdl/lt__alloc.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/lt__alloc.c,v
retrieving revision 1.3
diff -u -r1.3 lt__alloc.c
--- libltdl/lt__alloc.c 15 Jul 2004 12:14:47 -0000      1.3
+++ libltdl/lt__alloc.c 27 Sep 2004 18:46:14 -0000
@@ -82,7 +82,11 @@
 void *
 lt__memdup (void const *mem, size_t n)
 {
-  return memcpy (lt__malloc (n), mem, n);
+  void *newmem;
+
+  if ((newmem = lt__malloc (n)))
+    return memcpy (newmem, mem, n);
+  return 0;
 }
 
 char *
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.213
diff -u -r1.213 ltdl.c
--- libltdl/ltdl.c      2 Sep 2004 13:27:24 -0000       1.213
+++ libltdl/ltdl.c      27 Sep 2004 19:10:27 -0000
@@ -1986,9 +1986,11 @@
 lt_dlcaller_register (const char *id_string, lt_dlhandle_interface *iface)
 {
   lt__caller_id *caller_id = lt__malloc (sizeof *caller_id);
-
-  caller_id->id_string = lt__strdup (id_string);
-  caller_id->iface = iface;
+  if (caller_id)
+    {
+      caller_id->id_string = lt__strdup (id_string);
+      caller_id->iface = iface;
+    }
 
   return (lt_dlcaller_id) caller_id;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]