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

This commit is contained in:
Marcus Meissner 2008-03-01 23:12:26 +01:00 committed by Alexandre Julliard
parent dd997c1de6
commit 088a33729a
2 changed files with 7 additions and 2 deletions

View File

@ -2344,7 +2344,12 @@ BOOL WINAPI PathCanonicalizeA(LPSTR lpszBuf, LPCSTR lpszPath)
{
WCHAR szPath[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);
WideCharToMultiByte(CP_ACP,0,szBuff,-1,lpszBuf,MAX_PATH,0,0);
}

View File

@ -908,9 +908,9 @@ static void test_PathCanonicalizeA(void)
lstrcpy(dest, "test");
SetLastError(0xdeadbeef);
res = PathCanonicalizeA(dest, too_long);
ok(!res, "Expected failure\n");
todo_wine
{
ok(!res, "Expected failure\n");
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));