From: Dirk Mueller Date: Wed, 15 Aug 2007 21:38:31 +0000 (+0000) Subject: * libltdl/ltdl.c (parse_dotla_file): Avoid a strlen. When X-Git-Tag: release-2-1b~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5df8072046a04efd9e1f49fb027015b088f544a;p=thirdparty%2Flibtool.git * libltdl/ltdl.c (parse_dotla_file): Avoid a strlen. When reading .la files, cope with files that are not newline-terminated. --- diff --git a/ChangeLog b/ChangeLog index f8ed662d4..9ceb66048 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-08-15 Dirk Mueller (tiny change) + Ralf Wildenhues + + * libltdl/ltdl.c (parse_dotla_file): Avoid a strlen. When + reading .la files, cope with files that are not + newline-terminated. + 2007-08-05 Tilman Koschnick (tiny change) * libltdl/m4/libtool.m4 (_LT_COMPILER_PIC, _LT_LANG_CXX_CONFIG) diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 41e9f0799..75c7a6e55 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -1017,14 +1017,16 @@ parse_dotla_file(FILE *file, char **dlname, char **libdir, char **deplibs, while (!feof (file)) { + line[line_len-2] = '\0'; if (!fgets (line, (int) line_len, file)) { break; } /* 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') && (!feof (file))) + that is longer than the initial buffer size. + Behave even if the file contains NUL bytes due to corruption. */ + while (line[line_len-2] != '\0' && line[line_len-2] != '\n' && !feof (file)) { line = REALLOC (char, line, line_len *2); if (!line) @@ -1033,6 +1035,7 @@ parse_dotla_file(FILE *file, char **dlname, char **libdir, char **deplibs, ++errors; goto cleanup; } + line[line_len * 2 - 2] = '\0'; if (!fgets (&line[line_len -1], (int) line_len +1, file)) { break;