urlapi: setting a blank URL ("") is not an ok URL

Test it in 1560
Fixes #11714
Reported-by: ad0p on github
Closes #11715
This commit is contained in:
Daniel Stenberg 2023-08-23 14:30:17 +02:00
parent 5e2beb3395
commit 887b998e6e
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 6 additions and 0 deletions

View File

@ -1816,6 +1816,10 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
char *oldurl;
char *redired_url;
if(!nalloc)
/* a blank URL is not a valid URL */
return CURLUE_MALFORMED_INPUT;
/* if the new thing is absolute or the old one is not
* (we could not get an absolute url in 'oldurl'),
* then replace the existing with the new. */

View File

@ -151,6 +151,8 @@ struct clearurlcase {
};
static const struct testcase get_parts_list[] ={
{"", "", 0, 0, CURLUE_MALFORMED_INPUT},
{" ", "", 0, 0, CURLUE_MALFORMED_INPUT},
{"1h://example.net", "", 0, 0, CURLUE_BAD_SCHEME},
{"..://example.net", "", 0, 0, CURLUE_BAD_SCHEME},
{"-ht://example.net", "", 0, 0, CURLUE_BAD_SCHEME},