summaryrefslogtreecommitdiff
path: root/lib/idn.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2023-02-24 18:17:33 +0100
committerDaniel Stenberg <daniel@haxx.se>2023-02-27 15:12:29 +0100
commitcf3e6ce92f1c9686129d0fd4a5d39c0fb38792ec (patch)
tree5336ae7bc25263faa9506a2304703f17fb03b695 /lib/idn.c
parent49a9f13c3997494aee368f0b2c4104b370f509e6 (diff)
downloadcurl-cf3e6ce92f1c9686129d0fd4a5d39c0fb38792ec.tar.gz
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
Diffstat (limited to 'lib/idn.c')
-rw-r--r--lib/idn.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/idn.c b/lib/idn.c
index abba895c4..5f4b07e01 100644
--- 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 */