]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/ltdl.c [cygwin, mingw] (opendir): Fix write of constant
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 18 Dec 2004 20:47:37 +0000 (20:47 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 18 Dec 2004 20:47:37 +0000 (20:47 +0000)
strings past end of buffer.
(opendir, readdir): Fix read past end of buffer.

ChangeLog
libltdl/ltdl.c

index b73d47ed9dbacbacbef5c86dd9e54de91cc1b53a..eacd43f80bc43e3d9267b0c84e0cbc02d49b68ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-12-18  Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+       * 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 <Ralf.Wildenhues@gmx.de>
 
        * README-alpha: Update list of non-Libtool-owned files.
index c89690c02101b8da907e030c740a29f3d6586e90..f10bcf85d732e86b8a19b6643007afb78decd373 100644 (file)
@@ -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);
 }