try_dlopen() has a bug: it sometimes returns a handle if a dependency
authorfcusack <fcusack>
Fri, 23 Jun 2006 04:55:50 +0000 (04:55 +0000)
committerfcusack <fcusack>
Fri, 23 Jun 2006 04:55:50 +0000 (04:55 +0000)
library can't be loaded.  It also returns an error status, however
lt_dlopenext() doesn't handle this well and returns the invalid handle.
This causes a segfault instead of a graceful exit.  Update ltdl to
give an error telling the user to report the problem, so that we can
try to reproduce it and report to the libtool folks.  We could just
leave ltdl unpatched; FR will exit either way.

libltdl/ltdl.c
libltdl/ltdl.h

index 3da37c8..57c2a39 100644 (file)
@@ -3496,6 +3496,10 @@ lt_dlopenext (filename)
   strcpy (tmp, filename);
   strcat (tmp, archive_ext);
   errors = try_dlopen (&handle, tmp);
+  if (handle && errors) {
+    LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FR_DEPLIB));
+    return 0;  /* leaks tmp and handle */
+  }
 
   /* If we found FILENAME, stop searching -- whether we were able to
      load the file as a module or not.  If the file exists but loading
@@ -3526,6 +3530,10 @@ lt_dlopenext (filename)
 
   strcat(tmp, shlib_ext);
   errors = try_dlopen (&handle, tmp);
+  if (handle && errors) {
+    LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FR_DEPLIB));
+    return 0;  /* leaks tmp and handle */
+  }
 
   /* As before, if the file was found but loading failed, return now
      with the current error message.  */
index 8aaf342..42d3fa3 100644 (file)
@@ -329,7 +329,8 @@ LT_SCOPE    int             lt_dlloader_remove  LT_PARAMS((
     LT_ERROR(SHUTDOWN,             "library already shutdown")         \
     LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module")     \
     LT_ERROR(INVALID_MUTEX_ARGS,    "invalid mutex handler registration") \
-    LT_ERROR(INVALID_POSITION,     "invalid search path insert position")
+    LT_ERROR(INVALID_POSITION,     "invalid search path insert position") \
+    LT_ERROR(FR_DEPLIB,                    "dep lib loading bug, please report to freeradius-devel@lists.freeradius.org")
 
 /* Enumerate the symbolic error names. */
 enum {