From 2245d7a7967fcaedfc1407e42179c462269363dd Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sat, 18 Dec 2004 20:47:37 +0000 Subject: [PATCH] * libltdl/ltdl.c [cygwin, mingw] (opendir): Fix write of constant strings past end of buffer. (opendir, readdir): Fix read past end of buffer. --- ChangeLog | 6 ++++++ libltdl/ltdl.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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); } -- 2.47.3