From: Timo Sirainen Date: Tue, 10 Mar 2026 20:09:42 +0000 (+0200) Subject: lib: punycode_decode() - Fix parsing empty string [after delimiter] X-Git-Tag: 2.4.3~100 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=faee72d64d5a014361b8ecbfffefd9761766029d;p=thirdparty%2Fdovecot%2Fcore.git lib: punycode_decode() - Fix parsing empty string [after delimiter] This caused an assert crash when --enable-experimental-mail-utf8 was used and invalid punycode domain was being parsed. Based on code by rootvector2 (Dexter.k) --- diff --git a/src/lib/punycode.c b/src/lib/punycode.c index 1c8853a8b6..c9e03a5f8d 100644 --- a/src/lib/punycode.c +++ b/src/lib/punycode.c @@ -90,6 +90,8 @@ int punycode_decode(const char *input, size_t len, string_t *output) ptr = delim + 1; else ptr = input; + if (ptr == end) + return -1; i_assert(ptr < end); while (ptr < end) { diff --git a/src/lib/test-punycode.c b/src/lib/test-punycode.c index 485a5cfa42..f6ed829de2 100644 --- a/src/lib/test-punycode.c +++ b/src/lib/test-punycode.c @@ -25,6 +25,8 @@ static void test_punycode_decode(void) .ret = 0 }, /* broken */ { .in = "zz-zzzz", .out = "", .ret = -1 }, + { .in = "zz-", .out = "", .ret = -1 }, + { .in = "", .out = "", .ret = -1 }, }; unsigned int i;