Marcus Meissner : shlwapi: Handle buffer overflow on A->W converter.
Alexandre Julliard
julliard at winehq.org
Mon Mar 3 06:21:23 CST 2008
Module: wine
Branch: master
Commit: 088a33729ae8285c92c278dad91803c8ab19fa08
URL: http://source.winehq.org/git/wine.git/?a=commit;h=088a33729ae8285c92c278dad91803c8ab19fa08
Author: Marcus Meissner <marcus at jet.franken.de>
Date: Sat Mar 1 23:12:26 2008 +0100
shlwapi: Handle buffer overflow on A->W converter.
---
dlls/shlwapi/path.c | 7 ++++++-
dlls/shlwapi/tests/path.c | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c
index b2005c1..ae9c991 100644
--- a/dlls/shlwapi/path.c
+++ b/dlls/shlwapi/path.c
@@ -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);
}
diff --git a/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c
index 82112a5..b2d2a9e 100644
--- a/dlls/shlwapi/tests/path.c
+++ b/dlls/shlwapi/tests/path.c
@@ -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));
More information about the wine-cvs
mailing list