[PATCH] shlwapi: Handle PathCanonicalize with too long paths
Marcus Meissner
marcus at jet.franken.de
Thu Feb 28 16:15:34 CST 2008
Hi,
make test was crashing for me in this place, fixed by actually
checking the return value of MultiByteToWideChar and adjusting
the lasterror handling.
remove wine_todo{} from test.
Ciao, Marcus
---
dlls/shlwapi/path.c | 9 ++++++++-
dlls/shlwapi/tests/path.c | 7 ++-----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/dlls/shlwapi/path.c b/dlls/shlwapi/path.c
index b2005c1..3980532 100644
--- a/dlls/shlwapi/path.c
+++ b/dlls/shlwapi/path.c
@@ -2344,7 +2344,14 @@ BOOL WINAPI PathCanonicalizeA(LPSTR lpszBuf, LPCSTR lpszPath)
{
WCHAR szPath[MAX_PATH];
WCHAR szBuff[MAX_PATH];
- MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
+ DWORD le = GetLastError();
+ int ret = MultiByteToWideChar(CP_ACP,0,lpszPath,-1,szPath,MAX_PATH);
+
+ if (!ret) {
+ FIXME("Failed to convert string to widechar (too long?), LE %d.\n", GetLastError());
+ SetLastError (le); /* failure does not change Lasterror, see testcase. */
+ 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..798db8a 100644
--- a/dlls/shlwapi/tests/path.c
+++ b/dlls/shlwapi/tests/path.c
@@ -908,11 +908,8 @@ static void test_PathCanonicalizeA(void)
lstrcpy(dest, "test");
SetLastError(0xdeadbeef);
res = PathCanonicalizeA(dest, too_long);
- todo_wine
- {
- ok(!res, "Expected failure\n");
- ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
- }
+ 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));
}
--
1.5.2.4
More information about the wine-patches
mailing list