Bug fix in DOSFS_DoGetFullPathName

Robert Shearman R.J.Shearman at warwick.ac.uk
Sat Jan 11 19:38:09 CST 2003


Hi,

This fixes a bug in DOSFS_DoGetFullPathName that caused the following effect
in native cmd.exe:

C:\Windows>cd..
*no effect*
C:\Windows>cd..
*crashes*

It now makes sure that "cd F:\.." doesn't crash it and that the format of
the path returned is always "F:\" rather than "F:"

ChangeLog:
- Fix a bug that caused "cd F:\.." to crash
- Fix a bug that caused "F:" rather than "F:\" to sometimes be returned
(which is not liked by some programs)

Rob
-------------- next part --------------
Index: wine/files/dos_fs.c
===================================================================
RCS file: /home/wine/wine/files/dos_fs.c,v
retrieving revision 1.127
diff -u -r1.127 dos_fs.c
--- wine/files/dos_fs.c	13 Dec 2002 20:30:06 -0000	1.127
+++ wine/files/dos_fs.c	11 Jan 2003 21:07:32 -0000
@@ -1556,13 +1556,25 @@
 	   return "c:\test" */
 	  *(full_name.short_name+namelen-3)=0;
           q = strrchrW(full_name.short_name, '\\');
-	  *q =0;
+	  if (q) /* fix for example f:\.. */
+	      *q =0;
 	}
     if (full_name.short_name[namelen-1]=='.')
 	full_name.short_name[(namelen--)-1] =0;
     if (!driveletter)
       if (full_name.short_name[namelen-1]=='\\')
 	full_name.short_name[(namelen--)-1] =0;
+
+    /* this is so the function returns "c:\" whenever it
+     * wants to return "c:" like the native implementation
+     * and Win2k cmd.exe expects this */
+    if (full_name.short_name[0] &&
+        full_name.short_name[1] == ':' &&
+	!full_name.short_name[2])
+    {
+        full_name.short_name[2] = '\\';
+	full_name.short_name[3] = '\0';
+    }
     TRACE("got %s\n", debugstr_w(full_name.short_name));
 
     /* If the lpBuffer buffer is too small, the return value is the
@@ -1915,10 +1927,17 @@
     HGLOBAL handle;
     FIND_FIRST_INFO *info;
 
+    TRACE("(%s, ...)\n", debugstr_w(lpFileName));
+
     if (!lpFileName)
     {
         SetLastError(ERROR_PATH_NOT_FOUND);
         return INVALID_HANDLE_VALUE;
+    }
+    if (lpFileName[0] && lpFileName[1] == ':' && lpFileName[2] == '\\' && !lpFileName[3])
+    {
+        SetLastError(ERROR_NO_MORE_FILES);
+	return INVALID_HANDLE_VALUE;
     }
 
     if ((fSearchOp != FindExSearchNameMatch) || (dwAdditionalFlags != 0))


More information about the wine-patches mailing list