]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
idn: return error if the conversion ends up with a blank host
authorDaniel Stenberg <daniel@haxx.se>
Fri, 24 Feb 2023 17:17:33 +0000 (18:17 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 27 Feb 2023 14:12:29 +0000 (15:12 +0100)
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

lib/idn.c

index abba895c45e6d06231606d8a157528bfadb9f662..5f4b07e01847f2cb391898a87d07befa3bad75be 100644 (file)
--- a/lib/idn.c
+++ b/lib/idn.c
@@ -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 */