Commit 088a3372 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

shlwapi: Handle buffer overflow on A->W converter.

parent dd997c1d
...@@ -2344,7 +2344,12 @@ BOOL WINAPI PathCanonicalizeA(LPSTR lpszBuf, LPCSTR lpszPath) ...@@ -2344,7 +2344,12 @@ BOOL WINAPI PathCanonicalizeA(LPSTR lpszBuf, LPCSTR lpszPath)
{ {
WCHAR szPath[MAX_PATH]; WCHAR szPath[MAX_PATH];
WCHAR szBuff[MAX_PATH]; WCHAR szBuff[MAX_PATH];
MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH); int ret = MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
if (!ret) {
WARN("Failed to convert string to widechar (too long?), LE %d.\n", GetLastError());
return FALSE;
}
bRet = PathCanonicalizeW(szBuff, szPath); bRet = PathCanonicalizeW(szBuff, szPath);
WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszBuf,MAX_PATH,0,0); WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszBuf,MAX_PATH,0,0);
} }
......
...@@ -908,9 +908,9 @@ static void test_PathCanonicalizeA(void) ...@@ -908,9 +908,9 @@ static void test_PathCanonicalizeA(void)
lstrcpy(dest, "test"); lstrcpy(dest, "test");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
res = PathCanonicalizeA(dest, too_long); res = PathCanonicalizeA(dest, too_long);
ok(!res, "Expected failure\n");
todo_wine todo_wine
{ {
ok(!res, "Expected failure\n");
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
} }
ok(lstrlen(too_long) == LONG_LEN - 1, "Expected length LONG_LEN - 1, got %i\n", lstrlen(too_long)); ok(lstrlen(too_long) == LONG_LEN - 1, "Expected length LONG_LEN - 1, got %i\n", lstrlen(too_long));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment