Fixes for makepath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





ChangeLog:

     1. Avoid possible seg fault when calling TRACE with NULL string pointers.
     2. Fix bad side-effect of makepath on input parameters.

Description:

     2. Use a temporary buffer for the output path generation process instead
     of the output parameter directly. Otherwise, problems can occur in the case
     when the output string pointer is the same as one of the input parameter.
     Windows makepath function doesn't suffer from this bug.

Warren Baird : Warren_Baird@cimmetry.com
Dave Belanger
Louis Thibault

diff -ur clean/wine/dlls/msvcrt/dir.c wine/dlls/msvcrt/dir.c
--- clean/wine/dlls/msvcrt/dir.c   Wed Jan 29 15:30:35 2003
+++ wine/dlls/msvcrt/dir.c    Mon Feb  3 11:52:55 2003
@@ -677,37 +677,43 @@
                               const char * extension )
 {
     char ch;
-    TRACE("got %s %s %s %s\n", drive, directory,
-          filename, extension);
+    char tmpPath[MAX_PATH];
+    TRACE("got %s %s %s %s\n",
+           drive ? drive : "",
+           directory ? directory : "",
+           filename ? filename : "",
+           extension ? extension : "");

     if ( !path )
         return;

-    path[0] = 0;
+    tmpPath[0] = '\0';
     if (drive && drive[0])
     {
-        path[0] = drive[0];
-        path[1] = ':';
-        path[2] = 0;
+        tmpPath[0] = drive[0];
+        tmpPath[1] = ':';
+        tmpPath[2] = 0;
     }
     if (directory && directory[0])
     {
-        strcat(path, directory);
-        ch = path[strlen(path)-1];
+        strcat(tmpPath, directory);
+        ch = tmpPath[strlen(tmpPath)-1];
         if (ch != '/' && ch != '\\')
-            strcat(path,"\\");
+            strcat(tmpPath,"\\");
     }
     if (filename && filename[0])
     {
-        strcat(path, filename);
+        strcat(tmpPath, filename);
         if (extension && extension[0])
         {
             if ( extension[0] != '.' )
-                strcat(path,".");
-            strcat(path,extension);
+                strcat(tmpPath,".");
+            strcat(tmpPath,extension);
         }
     }
-
+
+    strcpy( path, tmpPath );
+
     TRACE("returning %s\n",path);
 }





[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux