Windows will stop processing at the first null, even when given an explicit length.
Signed-off-by: Tim Clem tclem@codeweavers.com --- dlls/wininet/tests/url.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/dlls/wininet/tests/url.c b/dlls/wininet/tests/url.c index bce7dc76c59..681b6ef0b32 100644 --- a/dlls/wininet/tests/url.c +++ b/dlls/wininet/tests/url.c @@ -653,6 +653,15 @@ static void InternetCrackUrl_test(void) GLE = GetLastError(); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(GLE == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "Expected GLE to represent a failure\n"); + + /* Windows treats dwUrlLength as a maximum - if there is a null before + * that length, it stops there. */ + 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); }
static void InternetCrackUrlW_test(void) @@ -825,6 +834,19 @@ static void InternetCrackUrlW_test(void) ok(r, "InternetCrackUrlW failed unexpectedly\n"); ok(!strcmp_wa(host, "x.org"), "host is %s, should be x.org\n", wine_dbgstr_w(host)); todo_wine ok(urlpart[0] == 0, "urlpart should be empty\n"); + + /* Windows treats dwUrlLength as a maximum - if there is a null before + * that length, it stops there. */ + host[0] = 0; + memset(&comp, 0, sizeof(comp)); + comp.dwStructSize = sizeof(comp); + comp.lpszHostName = host; + 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); }
static void fill_url_components(URL_COMPONENTSA *lpUrlComponents)