[PATCH 7/7] kernel32: Revise GetLongPathNameA to avoid overriding the input on long names

Jeremy White jwhite at codeweavers.com
Mon Dec 21 10:51:58 CST 2015


Windows appears to only override the input file name if the file
has a long name.

This fixes bug https://bugs.winehq.org/show_bug.cgi?id=36859.

Signed-off-by: Jeremy White <jwhite at codeweavers.com>
---
 dlls/kernel32/path.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index ae211cc..b12c71e 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -292,6 +292,7 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen
     BOOL                unixabsolute;
     WIN32_FIND_DATAW    wfd;
     HANDLE              goit;
+    BOOL                is_legal_8dot3;
 
     if (!shortpath)
     {
@@ -365,7 +366,7 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen
             }
         }
 
-        /* Check if the file exists and use the existing file name */
+        /* Check if the file exists */
         goit = FindFirstFileW(tmplongpath, &wfd);
         if (goit == INVALID_HANDLE_VALUE)
         {
@@ -374,7 +375,12 @@ DWORD WINAPI GetLongPathNameW( LPCWSTR shortpath, LPWSTR longpath, DWORD longlen
             return 0;
         }
         FindClose(goit);
-        strcpyW(tmplongpath + lp, wfd.cFileName);
+
+        is_legal_8dot3 = FALSE;
+        CheckNameLegalDOS8Dot3W(tmplongpath + lp, NULL, 0, NULL, &is_legal_8dot3);
+        /* Use the existing file name if it's a short name */
+        if (is_legal_8dot3)
+            strcpyW(tmplongpath + lp, wfd.cFileName);
         lp += strlenW(tmplongpath + lp);
         sp += tmplen;
     }
-- 
2.1.4




More information about the wine-patches mailing list