kernel32: GetTempPathW must zero the remaining buffer.

This commit is contained in:
Bruno Jesus 2015-02-28 20:11:08 -03:00 committed by Alexandre Julliard
parent 050bda2ece
commit f16cf54106
2 changed files with 5 additions and 2 deletions

View File

@ -623,9 +623,13 @@ DWORD WINAPI GetTempPathW( DWORD count, LPWSTR path )
if (count) if (count)
{ {
lstrcpynW(path, tmp_path, count); lstrcpynW(path, tmp_path, ret);
if (count >= ret) if (count >= ret)
{
/* the remaining buffer must be zeroed */
memset(path + ret, 0, (count - ret) * sizeof(WCHAR));
ret--; /* return length without 0 */ ret--; /* return length without 0 */
}
else if (count < 4) else if (count < 4)
path[0] = 0; /* avoid returning ambiguous "X:" */ path[0] = 0; /* avoid returning ambiguous "X:" */
} }

View File

@ -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"); ok(len == lstrlenW(buf), "returned length should be equal to the length of string\n");
/* The rest of the buffer must be zeroed */ /* The rest of the buffer must be zeroed */
for(len++; len < sizeof(buf) / sizeof(buf[0]); len++) 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]); ok(buf[len] == '\0', "expected NULL at [%d], got 0x%x\n", len, buf[len]);
} }