From: Ralf Wildenhues Date: Sat, 18 Dec 2004 20:47:37 +0000 (+0000) Subject: * libltdl/ltdl.c [cygwin, mingw] (opendir): Fix write of constant X-Git-Tag: release-1-5-12~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2245d7a7967fcaedfc1407e42179c462269363dd;p=thirdparty%2Flibtool.git * libltdl/ltdl.c [cygwin, mingw] (opendir): Fix write of constant strings past end of buffer. (opendir, readdir): Fix read past end of buffer. --- diff --git a/ChangeLog b/ChangeLog index b73d47ed9..eacd43f80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-12-18 Ralf Wildenhues + + * libltdl/ltdl.c [cygwin, mingw] (opendir): Fix write of constant + strings past end of buffer. + (opendir, readdir): Fix read past end of buffer. + 2004-12-17 Ralf Wildenhues * README-alpha: Update list of non-Libtool-owned files. diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index c89690c02..f10bcf85d 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -457,7 +457,9 @@ opendir (path) DIR *entry; assert(path != (char *) NULL); - (void) strncpy(file_specification,path,LT_FILENAME_MAX-1); + /* allow space for: path + '\\' '\\' '*' '.' '*' + '\0' */ + (void) strncpy (file_specification, path, LT_FILENAME_MAX-6); + file_specification[LT_FILENAME_MAX-6] = LT_EOS_CHAR; (void) strcat(file_specification,"\\"); entry = LT_DLMALLOC (DIR,sizeof(DIR)); if (entry != (DIR *) 0) @@ -498,6 +500,7 @@ static struct dirent *readdir(entry) entry->firsttime = FALSE; (void) strncpy(entry->file_info.d_name,entry->Win32FindData.cFileName, LT_FILENAME_MAX-1); + entry->file_info.d_name[LT_FILENAME_MAX - 1] = LT_EOS_CHAR; entry->file_info.d_namlen = strlen(entry->file_info.d_name); return(&entry->file_info); }