From adf5912c040eced9e11f3b8e32aa6ea17c7bfbea Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Tue, 9 Mar 1999 23:00:24 +0000 Subject: [PATCH] * libltdl/ltdl.c (lt_dlopen): don't hardcode the length of the constant strings --- ChangeLog | 5 +++++ libltdl/configure.in | 2 +- libltdl/ltdl.c | 28 ++++++++++++++++++++-------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 885f64a59..33ce98642 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +1999-03-09 Thomas Tanner + + * libltdl/ltdl.c (lt_dlopen): don't hardcode the length of the + constant strings + 1999-03-09 Alexandre Oliva * Makefile.am (install-data-hook): install libltdl as a directory, diff --git a/libltdl/configure.in b/libltdl/configure.in index 93afeedf2..a1156eb77 100644 --- a/libltdl/configure.in +++ b/libltdl/configure.in @@ -10,7 +10,7 @@ TOINST=toinst AC_SUBST(TOINST) if test -z "$enable_ltdl_install$enable_ltdl_convenience"; then - AC_MSG_WARN([*** Neither AC_LIBLTDL_INSTALLABLE nor AC_LIBLTDL_CONVENIENCE wre used]) + AC_MSG_WARN([*** Neither AC_LIBLTDL_INSTALLABLE nor AC_LIBLTDL_CONVENIENCE were used]) AC_MSG_WARN([*** in configure.in; building convenience library for backward]) AC_MSG_WARN([*** compatibility. This is deprecated, and will not work in the future]) enable_ltdl_convenience=yes diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 63bb2be56..b05150694 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -1142,23 +1142,35 @@ lt_dlopen (filename) } /* read the .la file */ while (!feof(file)) { + #define STR_DLNAME "dlname=" + #define STR_OLD_LIBRARY "old_library=" + #define STR_LIBDIR "libdir=" + #define STR_DL_DEPLIBS "dl_dependency_libs=" char line[LTDL_FILENAME_MAX]; if (!fgets(line, sizeof(line), file)) break; if (line[0] == '\n' || line[0] == '#') continue; - if (strncmp(line, "dlname=", 7) == 0) - error = trim(&dlname, &line[7]); + if (strncmp(line, STR_DLNAME, + sizeof(STR_DLNAME) - 1) == 0) + error = trim(&dlname, + &line[sizeof(STR_DLNAME) - 1]); else - if (strncmp(line, "old_library=", 12) == 0) - error = trim(&old_name, &line[12]); + if (strncmp(line, STR_OLD_LIBRARY, + sizeof(STR_OLD_LIBRARY) - 1) == 0) + error = trim(&old_name, + &line[sizeof(STR_OLD_LIBRARY) - 1]); else - if (strncmp(line, "libdir=", 7) == 0) - error = trim(&libdir, &line[7]); + if (strncmp(line, STR_LIBDIR, + sizeof(STR_LIBDIR) - 1) == 0) + error = trim(&libdir, + &line[sizeof(STR_LIBDIR) - 1]); else - if (strncmp(line, "dl_dependency_libs=", 20) == 0) - error = trim(&deplibs, &line[20]); + if (strncmp(line, STR_DL_DEPLIBS, + sizeof(STR_DL_DEPLIBS) - 1) == 0) + error = trim(&deplibs, + &line[sizeof(STR_DL_DEPLIBS) - 1]); else if (strcmp(line, "installed=yes\n") == 0) installed = 1; -- 2.47.3