Commit 681ce692 authored by Tim Clem's avatar Tim Clem Committed by Alexandre Julliard

wininet: Make heap_strndupAtoW stop at the first null.

The analogous heap_strndupW already does this. Fixes InternetCrackUrlA behavior when passed a dwUrlLength that's past the end of the string. Signed-off-by: 's avatarTim Clem <tclem@codeweavers.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent d4a417f8
......@@ -152,7 +152,10 @@ static inline WCHAR *heap_strndupAtoW(const char *str, int len_a, DWORD *len_w)
if(str) {
size_t len;
if(len_a < 0) len_a = strlen(str);
if(len_a < 0)
len_a = strlen(str);
else if(len_a > 0)
len_a = strnlen(str, len_a);
len = MultiByteToWideChar(CP_ACP, 0, str, len_a, NULL, 0);
ret = heap_alloc((len+1)*sizeof(WCHAR));
if(ret) {
......
......@@ -659,7 +659,6 @@ static void InternetCrackUrl_test(void)
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
ret = InternetCrackUrlA("http://x.org", 13 /* includes the nul */, 0, &urlComponents);
ok(ret, "InternetCrackUrlA failed with error %d\n", GetLastError());
todo_wine
ok(urlComponents.dwHostNameLength == 5,
"Expected dwHostNameLength of 5, got %d\n", urlComponents.dwHostNameLength);
......@@ -670,7 +669,6 @@ static void InternetCrackUrl_test(void)
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 1024, 1024);
ret = InternetCrackUrlA("http://x.org\0/x", 15, 0, &urlComponents);
ok(ret, "InternetCrackUrlA failed with error %d\n", GetLastError());
todo_wine
ok(urlComponents.dwUrlPathLength == 0,
"Expected dwUrlPathLength of 0, got %d\n", urlComponents.dwUrlPathLength);
}
......
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