PATCH: makepath - do not use stack buffer

Marcus Meissner meissner at suse.de
Tue Jan 17 07:16:56 CST 2006


Hi,

Do not use a temporary buffer in _makepath(), we can just operate
on the target buffer.

(This avoids overflowing tmpPath, which was just 256 byte large.)

This is the same as _wmakepath() does.

Ciao, Marcus

Changelog:
	_makepath(): operate on targetbuffer directly.

Index: dlls/msvcrt/dir.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/dir.c,v
retrieving revision 1.34
diff -u -r1.34 dir.c
--- dlls/msvcrt/dir.c	6 Jan 2006 20:53:18 -0000	1.34
+++ dlls/msvcrt/dir.c	17 Jan 2006 13:15:18 -0000
@@ -857,40 +857,37 @@
                const char * extension)
 {
     char ch;
-    char tmpPath[MAX_PATH];
-    TRACE("got %s %s %s %s\n", debugstr_a(drive), debugstr_a(directory),
+
+    TRACE("(%s %s %s %s)\n", debugstr_a(drive), debugstr_a(directory),
           debugstr_a(filename), debugstr_a(extension) );
 
     if ( !path )
         return;
 
-    tmpPath[0] = '\0';
+    path[0] = '\0';
     if (drive && drive[0])
     {
-        tmpPath[0] = drive[0];
-        tmpPath[1] = ':';
-        tmpPath[2] = 0;
+        path[0] = drive[0];
+        path[1] = ':';
+        path[2] = 0;
     }
     if (directory && directory[0])
     {
-        strcat(tmpPath, directory);
-        ch = tmpPath[strlen(tmpPath)-1];
+        strcat(path, directory);
+        ch = path[strlen(path)-1];
         if (ch != '/' && ch != '\\')
-            strcat(tmpPath,"\\");
+            strcat(path,"\\");
     }
     if (filename && filename[0])
     {
-        strcat(tmpPath, filename);
+        strcat(path, filename);
         if (extension && extension[0])
         {
             if ( extension[0] != '.' )
-                strcat(tmpPath,".");
-            strcat(tmpPath,extension);
+                strcat(path,".");
+            strcat(path,extension);
         }
     }
-
-    strcpy( path, tmpPath );
-
     TRACE("returning %s\n",path);
 }
 



More information about the wine-patches mailing list