Hi, Guile uses libtldl to do its dynamic linking and we decided to ship our own copy of it (suitably renamed) since we found that libltdl contained some showstopper bugs and we wanted be able to fix them quickly without having to wait for a libtool releases and also to be sure that people use the right version of libltdl. Please don't think of this as a fork; we hope that this way, we can better help to improve libltdl in general.
And so here is the first patch that we use (it's against 1.4.3). What do you think? 2002-10-04 Rob Browning <[EMAIL PROTECTED]> * ltdl.c: (memcpy): coerce ptrs to (char *) before copying characters through them -- I can't recall for sure, but I believe this was causing an overrun error at times. (realloc): Remove custom realloc. (#define rpl_realloc realloc) and comment out later code for custom realloc. You can't define your own malloc unless you know enough about the malloc in use to be able to tell how big the src ptr is. The disabled code incorrectly used the *destination* ptr to decide how much to copy. This sometimes results in out-of-bound accesses which cause segfaults. This is a quick hack for now; we may want something cleaner later. (tryall_dlopen_module): check to be sure (dirname_len > 0) before testing first character against '/'. (try_dlopen): check for feof(file) in read loop -- otherwise infloop? (LT_EOS_CHAR): moved here from guile-ltdl.h. 2002-10-04 Marius Vollmer <[EMAIL PROTECTED]> * raw-ltdl.c: (try_dlopen): Set newhandle to null when try_all_dlopen failed. (scm_lt_dlopenext): Reverse test of "file_not_found()". Previously, we would stop searching when the file wasn't found yet, while we should continue in that case. --- ltdl.h 2002-10-25 17:55:30.000000000 +0200 +++ raw-ltdl.guilemod.h 2002-10-26 16:32:35.000000000 +0200 @@ -1,5 +1,5 @@ /* ltdl.h -- generic dlopen functions - Copyright (C) 1998-2000 Free Software Foundation, Inc. + Copyright (C) 1998-2000, 2002 Free Software Foundation, Inc. Originally by Thomas Tanner <[EMAIL PROTECTED]> This file is part of GNU Libtool. @@ -28,15 +28,13 @@ #ifndef LTDL_H #define LTDL_H 1 #include <sys/types.h> /* for size_t declaration */ /* --- MACROS FOR PORTABILITY --- */ - -/* Saves on those hard to debug '\0' typos.... */ -#define LT_EOS_CHAR '\0' - /* LTDL_BEGIN_C_DECLS should be used at the beginning of your declarations, so that C++ compilers don't mangle their names. Use LTDL_END_C_DECLS at the end of C declarations. */ --- ltdl.c 2002-10-25 17:55:30.000000000 +0200 +++ raw-ltdl.guilemod.c 2002-10-26 16:32:35.000000000 +0200 @@ -1,5 +1,5 @@ /* ltdl.c -- system independent dlopen wrapper - Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc. Originally by Thomas Tanner <[EMAIL PROTECTED]> This file is part of GNU Libtool. @@ -26,7 +26,7 @@ */ #if HAVE_CONFIG_H # include <config.h> #endif #if HAVE_UNISTD_H @@ -92,13 +92,15 @@ # define assert(arg) ((void) 0) #endif #include "ltdl.h" #if WITH_DMALLOC # include <dmalloc.h> #endif +/* Saves on those hard to debug '\0' typos.... */ +#define LT_EOS_CHAR '\0' /* --- WINDOWS SUPPORT --- */ @@ -158,7 +160,7 @@ static lt_ptr lt_emalloc LT_PARAMS((size_t size)); static lt_ptr lt_erealloc LT_PARAMS((lt_ptr addr, size_t size)); -static lt_ptr rpl_realloc LT_PARAMS((lt_ptr ptr, size_t size)); +#define rpl_realloc realloc /* These are the pointers that can be changed by the caller: */ LT_GLOBAL_DATA lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size)) @@ -333,7 +335,7 @@ for (i = 0; i < size; ++i) { - dest[i] = src[i]; + ((char *) dest)[i] = ((char *) src)[i]; } return dest; @@ -379,8 +381,14 @@ Instead implement our own version (with known boundary conditions) using lt_dlmalloc and lt_dlfree. */ -#undef realloc -#define realloc rpl_realloc + +#if 0 + + /* You can't (re)define realloc unless you also (re)define malloc. + Right now, this code uses the size of the *destination* to decide + how much to copy. That's not right, but you can't know the size + of the source unless you know enough about, or wrote malloc. So + this code is disabled... */ static lt_ptr realloc (ptr, size) @@ -419,6 +427,8 @@ } } +#endif + #if ! HAVE_ARGZ_APPEND # define argz_append rpl_argz_append @@ -809,7 +819,6 @@ /* --- ERROR HANDLING --- */ - static const char **user_error_strings = NULL; static int errorcount = LT_ERROR_MAX; @@ -1976,8 +1985,9 @@ assert (strchr (dirname, LT_DIRSEP_CHAR) == NULL); #endif - if (dirname[dirname_len -1] == '/') - --dirname_len; + if (dirname_len > 0) + if (dirname[dirname_len -1] == '/') + --dirname_len; filename_len = dirname_len + 1 + LT_STRLEN (dlname); /* Allocate memory, and combine DIRNAME and MODULENAME into it. @@ -2721,7 +2731,7 @@ /* Handle the case where we occasionally need to read a line that is longer than the initial buffer size. */ - while (line[LT_STRLEN(line) -1] != '\n') + while ((line[LT_STRLEN(line) -1] != '\n') && (!feof (file))) { line = LT_DLREALLOC (char, line, line_len *2); if (!fgets (&line[line_len -1], (int) line_len +1, file)) @@ -2987,7 +2997,7 @@ failed, it is better to return an error message here than to report FILE_NOT_FOUND when the alternatives (foo.so etc) are not in the module search path. */ - if (handle || ((errors > 0) && file_not_found ())) + if (handle || ((errors > 0) && !file_not_found ())) { LT_DLFREE (tmp); return handle; @@ -3014,7 +3024,7 @@ /* As before, if the file was found but loading failed, return now with the current error message. */ - if (handle || ((errors > 0) && file_not_found ())) + if (handle || ((errors > 0) && !file_not_found ())) { LT_DLFREE (tmp); return handle; _______________________________________________ Libtool mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/libtool