Signed-off-by: Tim Clem tclem@codeweavers.com --- dlls/wininet/internet.c | 13 ++++++++++++- dlls/wininet/tests/url.c | 2 -- 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 1b6f060d607..c5b70e60d0c 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -1636,7 +1636,18 @@ BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwF SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } - if (!dwUrlLength) dwUrlLength = lstrlenW(lpszUrl); + + if (!dwUrlLength) + dwUrlLength = lstrlenW(lpszUrl); + else { + /* Windows stops at a null, regardless of what dwUrlLength says. */ + DWORD len = wcsnlen(lpszUrl, dwUrlLength); + if (dwUrlLength != len) { + TRACE("dwUrlLength %u is past a null terminator. Treating length as %u.\n", + dwUrlLength, len); + dwUrlLength = len; + } + }
if (dwFlags & ICU_DECODE) { diff --git a/dlls/wininet/tests/url.c b/dlls/wininet/tests/url.c index 9476d4309c3..59b66a5404c 100644 --- a/dlls/wininet/tests/url.c +++ b/dlls/wininet/tests/url.c @@ -855,7 +855,6 @@ static void InternetCrackUrlW_test(void) comp.dwHostNameLength = ARRAY_SIZE(host); r = InternetCrackUrlW(url3, 13 /* includes the nul */, 0, &comp); ok(r, "InternetCrackUrlW failed with error %d\n", GetLastError()); - todo_wine ok(comp.dwHostNameLength == 5, "Expected dwHostNameLength of 5, got %d\n", comp.dwHostNameLength);
@@ -877,7 +876,6 @@ static void InternetCrackUrlW_test(void) comp.dwUrlPathLength = ARRAY_SIZE(urlpart); r = InternetCrackUrlW(url5, 15, 0, &comp); ok(r, "InternetCrackUrlW failed with error %d\n", GetLastError()); - todo_wine ok(comp.dwUrlPathLength == 0, "Expected dwUrlPathLength of 0, got %d\n", comp.dwUrlPathLength); }