[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-patches
Subject:    kernel32: GetTempPathW must zero the remaining buffer (try 2)
From:       Bruno Jesus <00cpxxx () gmail ! com>
Date:       2015-02-28 23:11:08
Message-ID: CALF_nUQDU-GUz9O9BXhm2b7y11VaZb1wYPaz-kyXCmMO3pMefg () mail ! gmail ! com
[Download RAW message or body]

try 2:
remove wrong change

Fixes bug https://bugs.winehq.org/show_bug.cgi?id=34716

["k2.txt" (text/plain)]

diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 475b1f6..1048214 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -623,9 +623,13 @@ DWORD WINAPI GetTempPathW( DWORD count, LPWSTR path )
 
     if (count)
     {
-        lstrcpynW(path, tmp_path, count);
+        lstrcpynW(path, tmp_path, ret);
         if (count >= ret)
+        {
+            /* the remaining buffer must be zeroed */
+            memset(path + ret, 0, (count - ret) * sizeof(WCHAR));
             ret--; /* return length without 0 */
+        }
         else if (count < 4)
             path[0] = 0; /* avoid returning ambiguous "X:" */
     }
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 8b07b8f..a5c0f41 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -1012,7 +1012,6 @@ static void test_GetTempPathW(char* tmp_dir)
     ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
     /* The rest of the buffer must be zeroed */
     for(len++; len < sizeof(buf) / sizeof(buf[0]); len++)
-        todo_wine
         ok(buf[len] == '\0', "expected NULL at [%d], got 0x%x\n", len, buf[len]);
 }
 




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic