idn: return error if the conversion ends up with a blank host

Some IDN sequences are converted into "" (nothing), which can make this
function end up with a zero length host name and we cannot consider that
a valid host to continue with.

Reported-by: Maciej Domanski
Closes #10617
This commit is contained in:
Daniel Stenberg 2023-02-24 18:17:33 +01:00
parent 49a9f13c39
commit cf3e6ce92f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -184,6 +184,11 @@ CURLcode Curl_idnconvert_hostname(struct hostname *host)
if(!Curl_is_ASCII_name(host->name)) {
char *decoded = idn_decode(host->name);
if(decoded) {
if(!*decoded) {
/* zero length is a bad host name */
Curl_idn_free(decoded);
return CURLE_URL_MALFORMAT;
}
/* successful */
host->encalloc = decoded;
/* change the name pointer to point to the encoded hostname */