kernelbase: Return E_INVALIDARG when requesting URL_PART_PORT and there is no port.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-02-15 21:52:14 -06:00 committed by Alexandre Julliard
parent 67ea5ccc6b
commit 224d073388
2 changed files with 5 additions and 3 deletions

View File

@ -4347,6 +4347,8 @@ HRESULT WINAPI UrlGetPartW(const WCHAR *url, WCHAR *out, DWORD *out_len, DWORD p
break; break;
case URL_PART_PORT: case URL_PART_PORT:
if (!pl.port)
return E_INVALIDARG;
if (!pl.port_len) if (!pl.port_len)
{ {
*out = '\0'; *out = '\0';

View File

@ -624,7 +624,7 @@ static void test_UrlGetPart(void)
{"http://localhost/", URL_PART_USERNAME, 0, E_INVALIDARG}, {"http://localhost/", URL_PART_USERNAME, 0, E_INVALIDARG},
{"http://localhost/", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://localhost/", URL_PART_PASSWORD, 0, E_INVALIDARG},
{"http://localhost/", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://localhost/", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
{"http://localhost/", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://localhost/", URL_PART_PORT, 0, E_INVALIDARG},
{"http://localhost/", URL_PART_QUERY, 0, S_FALSE, ""}, {"http://localhost/", URL_PART_QUERY, 0, S_FALSE, ""},
{"http://localhost:port/", URL_PART_USERNAME, 0, E_INVALIDARG}, {"http://localhost:port/", URL_PART_USERNAME, 0, E_INVALIDARG},
@ -637,7 +637,7 @@ static void test_UrlGetPart(void)
{"http://user@localhost", URL_PART_USERNAME, 0, S_OK, "user"}, {"http://user@localhost", URL_PART_USERNAME, 0, S_OK, "user"},
{"http://user@localhost", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://user@localhost", URL_PART_PASSWORD, 0, E_INVALIDARG},
{"http://user@localhost", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://user@localhost", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
{"http://user@localhost", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://user@localhost", URL_PART_PORT, 0, E_INVALIDARG},
{"http://@", URL_PART_USERNAME, 0, S_FALSE, ""}, {"http://@", URL_PART_USERNAME, 0, S_FALSE, ""},
{"http://@", URL_PART_PASSWORD, 0, E_INVALIDARG}, {"http://@", URL_PART_PASSWORD, 0, E_INVALIDARG},
{"http://@", URL_PART_HOSTNAME, 0, S_FALSE, ""}, {"http://@", URL_PART_HOSTNAME, 0, S_FALSE, ""},
@ -645,7 +645,7 @@ static void test_UrlGetPart(void)
{"http://user:pass@localhost", URL_PART_USERNAME, 0, S_OK, "user"}, {"http://user:pass@localhost", URL_PART_USERNAME, 0, S_OK, "user"},
{"http://user:pass@localhost", URL_PART_PASSWORD, 0, S_OK, "pass"}, {"http://user:pass@localhost", URL_PART_PASSWORD, 0, S_OK, "pass"},
{"http://user:pass@localhost", URL_PART_HOSTNAME, 0, S_OK, "localhost"}, {"http://user:pass@localhost", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
{"http://user:pass@localhost", URL_PART_PORT, 0, E_INVALIDARG, .todo_hr = TRUE}, {"http://user:pass@localhost", URL_PART_PORT, 0, E_INVALIDARG},
{"http://:@", URL_PART_USERNAME, 0, S_FALSE, ""}, {"http://:@", URL_PART_USERNAME, 0, S_FALSE, ""},
{"http://:@", URL_PART_PASSWORD, 0, S_FALSE, ""}, {"http://:@", URL_PART_PASSWORD, 0, S_FALSE, ""},
{"http://:@", URL_PART_HOSTNAME, 0, S_FALSE, ""}, {"http://:@", URL_PART_HOSTNAME, 0, S_FALSE, ""},