]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
*** empty log message ***
authorThomas Tanner <tanner@gmx.de>
Sat, 9 Jan 1999 09:51:44 +0000 (09:51 +0000)
committerThomas Tanner <tanner@gmx.de>
Sat, 9 Jan 1999 09:51:44 +0000 (09:51 +0000)
15 files changed:
ChangeLog
NEWS
demo/Makefile.am
demo/configure.in
demo/dlmain.c
demo/foo.c
depdemo/Makefile.am
depdemo/configure.in
depdemo/l4.c
libltdl/ltdl.c
mdemo/Makefile.am
mdemo/configure.in
mdemo/foo1.c
mdemo/foo2.c
mdemo/main.c

index da494b12bb558d91fa5d42e832e71fa813e6c536..b5dbe69f6f5e3bd23d511481d8ceb9803fcf451b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+1999-01-09  Thomas Tanner  <tanner@gmx.de>
+
+       * NEWS: support for BSD/OS 4.x was not documented
+       * demo/Makefile.am: link against libm only if available
+       * mdemo/Makefile.am: likewise, use -avoid-versioning flag
+         instead of -avoid-version (typo)
+       * demo/configure.in: check for libm, string.h and math.h
+       * mdemo/configure.in: likewise
+       * depdemo/configure.in: check for libm and math.h
+       * libltdl/ltdl.c: check for buffer overflows
+       
 1999-01-07  Gary V. Vaughan  <gvaughan@oranda.demon.co.uk>
 
        * ltmain.sh (cygwin, allow_undefined): Unfortunately, there are
diff --git a/NEWS b/NEWS
index 1bfc362e41bfa5ce50bb491e3d7dcad637769dc7..bac6df3ae93cb64cdf59ed92589668deec6e0c7c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ NEWS - list of user-visible changes between releases of GNU Libtool
 
 New in 1.2e: CVS version:
 * Support for BeOS
-* Improved support for Win32, SysV 4.3 and NetBSD
+* Improved support for Win32, SysV 4.3, BSD/OS 4.x and NetBSD
 * Various bugfixes
 
 New in 1.2c: CVS version; 1.2d: 1998-12-16, Libtool team:
index ceb1519e5ea1275547b4d8d9e9d0da87f0cf8a25..9034bc4668428063740c1af74dda0ce62d8602d5 100644 (file)
@@ -10,7 +10,7 @@ CLEANFILES = $(hardcode_tests)
 # Build a libtool library, libhello.la for installation in libdir.
 lib_LTLIBRARIES = libhello.la
 libhello_la_SOURCES = hello.c foo.c
-libhello_la_LDFLAGS = -version-info 3:12:1 -lm
+libhello_la_LDFLAGS = -version-info 3:12:1 $(LIBADD_M)
 
 include_HEADERS = foo.h
 
index 2018f4e815e62432da231542ed7dbcecb2db09e5..97511c2eb72bee8cb141d3107891d409356d6b81 100644 (file)
@@ -9,5 +9,10 @@ AM_PROG_LIBTOOL
 AM_CONDITIONAL(BINARY_HELLDL, [dnl
 grep '^global_symbol_pipe=..*$' ./libtool >/dev/null])
 
+AC_CHECK_HEADERS(string.h math.h)
+
+AC_CHECK_LIB(m, cos, LIBADD_M="-lm", LIBADD_M=)
+AC_SUBST(LIBADD_M)
+
 dnl Output the makefile
 AC_OUTPUT(Makefile)
index 6a26c5961c4f99d634e547da94cca408aac7a5fc..aa0095d6093a66d180e8c6148861177b85115840 100644 (file)
@@ -19,7 +19,10 @@ USA. */
 
 #include "foo.h"
 #include <stdio.h>
+
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
 
 struct dld_symlist
 {
index 19b6e9b33bb90d769921ff2a7044461844ca64bf..d0661166d32b7db399e5d243e3aa5327103d2ea7 100644 (file)
@@ -23,7 +23,10 @@ USA. */
 #undef _LIBFOO_COMPILATION
 
 #include <stdio.h>
+
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
 
 /* Give a global variable definition. */
 int nothing = FOO_RET;
index 2143309285fc5f12ae531e3ad423c2efeeae5004..b4dfece39c6ef84bdb306a61dcddddb6541df56a 100644 (file)
@@ -9,7 +9,7 @@ libl2_la_LIBADD = libl1.la
 libl3_la_SOURCES = l3.c l3.h sysdep.h
 libl3_la_LIBADD = libl1.la libl2.la
 libl4_la_SOURCES = l4.c l4.h sysdep.h
-libl4_la_LIBADD = libl3.la -lm
+libl4_la_LIBADD = libl3.la $(LIBADD_M)
 
 bin_PROGRAMS = depdemo depdemo.static
 
index f1120a2a34dad69b7cc975bb702c3741f1197351..5a19db94e48bf7ac57a0be61d0a7c412e719af94 100644 (file)
@@ -6,7 +6,10 @@ AC_PROG_CC
 AC_EXEEXT
 AM_PROG_LIBTOOL
 
-AC_CHECK_HEADERS(string.h)
+AC_CHECK_HEADERS(math.h)
+
+AC_CHECK_LIB(m, cos, LIBADD_M="-lm", LIBADD_M=)
+AC_SUBST(LIBADD_M)
 
 dnl Output the makefile
 AC_OUTPUT(Makefile)
index 8a975fe72f710ed2e39e39f511e19c3f3cc00116..94019b93766c48d36aaf4f0804b65ec5363aa8d1 100644 (file)
@@ -21,7 +21,10 @@ USA. */
 
 #include "l3.h"
 #include <stdio.h>
+
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
 
 int    var_l4;
 
index 72736da5b0ca70117632ce2b42e39295c8f10153..516bd50ffa9f50ca0e71e9d2195e51ae70be9f3b 100644 (file)
@@ -628,7 +628,7 @@ tryall_dlopen (handle, filename)
 }
 
 #undef MAX_FILENAME
-#define MAX_FILENAME 1024
+#define MAX_FILENAME 2048
 
 static int
 find_module (handle, dir, libdir, dlname, old_name)
@@ -638,26 +638,32 @@ find_module (handle, dir, libdir, dlname, old_name)
        const char *dlname;
        const char *old_name;
 {
-       char    fullname[MAX_FILENAME]; /* FIXME: unchecked buffer */
+       char    fullname[MAX_FILENAME];
        
        /* search a module */
        if (*dlname) {
                /* try to open the installed module */
-               strcpy(fullname, libdir);
-               strcat(fullname, "/");
-               strcat(fullname, dlname);
-               if (tryall_dlopen(handle, fullname) == 0)
-                       return 0;
+               if (strlen(libdir)+strlen(dlname)+1 < MAX_FILENAME) {
+                       strcpy(fullname, libdir);
+                       strcat(fullname, "/");
+                       strcat(fullname, dlname);
+                       if (tryall_dlopen(handle, fullname) == 0)
+                               return 0;
+               }
                /* try to open the not-installed module */
-               strcpy(fullname, dir);
-               strcat(fullname, ".libs/");
-               strcat(fullname, dlname);
-               if (tryall_dlopen(handle, fullname) == 0)
-                       return 0;
-               strcpy(fullname, dir);
-               strcat(fullname, dlname);
-               if (tryall_dlopen(handle, fullname) == 0)
-                       return 0;
+               if (strlen(dir)+strlen(dlname)+6 < MAX_FILENAME) {
+                       strcpy(fullname, dir);
+                       strcat(fullname, ".libs/");
+                       strcat(fullname, dlname);
+                       if (tryall_dlopen(handle, fullname) == 0)
+                               return 0;
+               }
+               if (strlen(dir)+strlen(dlname) < MAX_FILENAME) {
+                       strcpy(fullname, dir);
+                       strcat(fullname, dlname);
+                       if (tryall_dlopen(handle, fullname) == 0)
+                               return 0;
+               }
        }
        if (*old_name && tryall_dlopen(handle, old_name) == 0)
                return 0;
@@ -678,25 +684,23 @@ lt_dlopen (filename)
 {
        lt_dlhandle handle;
        FILE    *file;
-       char    dir[MAX_FILENAME]; /* FIXME: unchecked buffer */
-       char    tmp[MAX_FILENAME]; /* FIXME: unchecked buffer */
+       char    dir[MAX_FILENAME];
+       char    tmp[MAX_FILENAME];
        const char *basename, *ext, *search_path;
        
-       handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
-       if (!handle)
-               return 0;
        basename = strrchr(filename, '/');
        if (basename)
                basename++;
        else
                basename = filename;
+       if (basename - filename >= MAX_FILENAME)
+               return 0;
        strncpy(dir, filename, basename - filename);
        dir[basename - filename] = '\0';
        search_path = getenv("LTDL_LIBRARY_PATH"); /* get the search path */
        /* check whether we open a libtool module (.la extension) */
        ext = strrchr(basename, '.');
        if (ext && strcmp(ext, ".la") == 0) {
-               /* FIXME: unchecked buffers */
                char    dlname[MAX_FILENAME], old_name[MAX_FILENAME];
                char    libdir[MAX_FILENAME], preload[MAX_FILENAME];
                int     i;
@@ -708,29 +712,35 @@ lt_dlopen (filename)
                        /* try other directories */
                        const char *p, *next;
                        
+                       /* search_path is a colon-separated
+                          list of search directories */
                        p = search_path;
                        while (!file && p) {
                                next = strchr(p, ':');
                                if (next) {
+                                       if (next - p + 1 >= MAX_FILENAME)
+                                               return 0;
                                        strncpy(dir, p, next - p);
                                        dir[next - p] = '\0';
                                        p = next+1;
                                } else {
+                                       if (strlen(p)+1 >= MAX_FILENAME)
+                                               return 0;
                                        strcpy(dir, p);
                                        p = 0;
                                }
                                if (!*dir)
                                        continue;
                                strcat(dir, "/");
-                               strcpy(tmp, dir);
-                               strcat(tmp, basename);
-                               file = fopen(tmp, READTEXT_MODE);
+                               if (strlen(dir)+strlen(basename) < MAX_FILENAME) {
+                                       strcpy(tmp, dir);
+                                       strcat(tmp, basename);
+                                       file = fopen(tmp, READTEXT_MODE);
+                               }
                        }
                }
-               if (!file) {
-                       free(handle);
+               if (!file)
                        return 0;
-               }
                while (!feof(file)) {
                        if (!fgets(tmp, MAX_FILENAME, file))
                                break;
@@ -747,13 +757,18 @@ lt_dlopen (filename)
                                trim(preload, &tmp[13]);
                }
                fclose(file);
-               /* TODO: preload required libraries */
+               /* FIXME: preload required libraries */
                
+               handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
+               if (!handle)
+                       return 0;
                if (find_module(&handle, dir, libdir, dlname, old_name)) {
                        free(handle);
                        return 0;
                }
                /* extract the module name from the file name */
+               if (basename >= MAX_FILENAME)
+                       return 0;
                strcpy(tmp, basename);
                tmp[ext - basename] = '\0';
                /* canonicalize the modul name */               
@@ -763,6 +778,10 @@ lt_dlopen (filename)
                handle->name = strdup(tmp);
        } else {
                /* not a libtool module */
+               handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
+               if (!handle)
+                       return 0;
+                       
                if (tryall_dlopen(*handle, filename)) {
                        int     error = 1;
                        
@@ -770,23 +789,31 @@ lt_dlopen (filename)
                                /* try other directories */
                                const char *p, *next;
                        
-                               p = search_path;
+                               /* search_path is a colon-separated
+                                  list of search directories */
+                               p = search_path; 
                                while (error && p) {
                                        next = strchr(p, ':');
                                        if (next) {
+                                               if (next - p + 1 >= MAX_FILENAME)
+                                                       return 0;
                                                strncpy(dir, p, next - p);
                                                dir[next - p] = '\0';
                                                p = next+1;
                                        } else {
+                                               if (strlen(p)+1 >= MAX_FILENAME)
+                                                       return 0;
                                                strcpy(dir, p);
                                                p = 0;
                                        }
                                        if (!*dir)
                                                continue;
                                        strcat(dir, "/");
-                                       strcpy(tmp, dir);
-                                       strcat(tmp, basename);
-                                       error = tryall_dlopen(*handle, tmp);
+                                       if (strlen(dir)+strlen(basename) < MAX_FILENAME) {
+                                               strcpy(tmp, dir);
+                                               strcat(tmp, basename);
+                                               error = tryall_dlopen(*handle, tmp);
+                                       }
                                }
                        }
                        if (error) {
@@ -834,33 +861,42 @@ lt_dlclose (handle)
        return 0;
 }
 
+#define MAX_SYMBOL_LENGTH      128
+
 lt_ptr_t
 lt_dlsym (handle, symbol)
        lt_dlhandle handle;
        const char *symbol;
 {
-       char    sym[128]; /* FIXME: unchecked buffer */
+       char    sym[MAX_SYMBOL_LENGTH];
        lt_ptr_t address;
 
-       if (handle->name) { /* this is a libtool module */
 #ifdef NEED_USCORE
+       if (handle->name && strlen(handle->name) < MAX_SYMBOL_LENGTH-6) {
+               /* this is a libtool module */
                /* prefix symbol with leading underscore */
                strcpy(sym, "_");
                strcat(sym, handle->name);
 #else
+       if (handle->name && strlen(handle->name) < MAX_SYMBOL_LENGTH-5) {
+               /* this is a libtool module */
                strcpy(sym, handle->name);
 #endif
                strcat(sym, "_LTX_");
-               strcat(sym, symbol);
-               /* try "modulename_LTX_symbol" */
-               address = handle->type->find_sym(handle, sym);
-               if (address)
-                       return address;
+               if (strlen(sym)+strlen(symbol) < MAX_SYMBOL_LENGTH) {
+                       strcat(sym, symbol);
+                       /* try "modulename_LTX_symbol" */
+                       address = handle->type->find_sym(handle, sym);
+                       if (address)
+                               return address;
+               }
        }
        /* otherwise try "symbol" */
 #ifdef NEED_USCORE
        /* prefix symbol with leading underscore */
        strcpy(sym, "_");
+       if (strlen(symbol) >= MAX_SYMBOL_LENGTH)
+               return 0;
        strcat(sym, symbol);
        return handle->type->find_sym(handle, sym);
 #else
index e7052884286a70609bcb8d7f92740e7d270d3bc7..5c8a63317b0131839c8107b1fa081645e8939ce4 100644 (file)
@@ -9,10 +9,10 @@ EXTRA_DIST = acinclude.m4
 lib_LTLIBRARIES = libfoo1.la libfoo2.la
 
 libfoo1_la_SOURCES = foo1.c
-libfoo1_la_LDFLAGS = -lm -module -avoid-version
+libfoo1_la_LDFLAGS = $(LIBADD_M) -module -avoid-versioning
 
 libfoo2_la_SOURCES = foo2.c
-libfoo2_la_LDFLAGS = -lm -module
+libfoo2_la_LDFLAGS = $(LIBADD_M) -module
 
 noinst_HEADERS = foo.h
 
@@ -21,7 +21,7 @@ bin_PROGRAMS = mdemo mdemo.debug
 # Create a version of mdemo that does dlopen.
 mdemo_SOURCES = main.c
 mdemo_LDADD = ../libltdl/libltdl.la \
-       -lm # We won't need this when libltdl takes care of dependencies
+       $(LIBADD_M) # We won't need this when libltdl takes care of dependencies
 mdemo_LDFLAGS = -export-dynamic -dlopen libfoo1.la -dlopen libfoo2.la
 mdemo_DEPENDENCIES = ../libltdl/libltdl.la libfoo1.la libfoo2.la
 
index 284a7c8fae3d45c2243d4fc3a190b42b9024ab39..374156e850d270f310e943046f39cc8d8e9f1b9a 100644 (file)
@@ -6,5 +6,10 @@ AC_PROG_CC
 AC_EXEEXT
 AM_PROG_LIBTOOL
 
+AC_CHECK_HEADERS(string.h math.h)
+
+AC_CHECK_LIB(m, cos, LIBADD_M="-lm", LIBADD_M=)
+AC_SUBST(LIBADD_M)
+
 dnl Output the makefile
 AC_OUTPUT(Makefile)
index edc7321da8b120c423c11d89c6729802b4d2bf41..d98c554b09e16ebd63fd53b1259048efede46cb9 100644 (file)
@@ -20,7 +20,10 @@ USA. */
 
 #include "foo.h"
 #include <stdio.h>
+
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
 
 #define nothing libfoo1_LTX_nothing
 #define foo1   libfoo1_LTX_foo1
index 588c3b8f3fbed77b74154dc2e4879867410a44de..4c8ddcc0290ef33da904b267802c9bdfb791803b 100644 (file)
@@ -20,7 +20,10 @@ USA. */
 
 #include "foo.h"
 #include <stdio.h>
+
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
 
 #define nothing libfoo2_LTX_nothing
 #define foo2   libfoo2_LTX_foo2
index 4f8e032fc241e9d79715b301648ca181d0f3e8e3..f72dcf0c6024cc1a4e11a3d931ae1a98de57f3da 100644 (file)
@@ -21,8 +21,14 @@ USA. */
 #include "foo.h"
 #include "ltdl.h"
 #include <stdio.h>
+
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
+
+#ifdef HAVE_MATH_H
 #include <math.h>
+#endif
 
 /* import sin and cos (used by the modules) */
 extern double sin (double x);