From c88b60342854d0f8c08de5e3fde2d964a422c386 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Thu, 26 Jan 2017 13:21:39 +0100 Subject: str-idna: improved error handling In addition to detecting input with invalid characters in _idn2_to_unicode_8z8z(), we also add support for case insensitive punycode header. Signed-off-by: Nikos Mavrogiannopoulos --- lib/str-idna.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/str-idna.c b/lib/str-idna.c index 383560ca3f..c7298acc24 100644 --- a/lib/str-idna.c +++ b/lib/str-idna.c @@ -164,10 +164,13 @@ static int _idn2_to_unicode_8z8z(const char *src, char **dst) out_len = 0; for (e = s = src; *e; s = e) { - while (*e && *e != '.') + while (*e && *e != '.') { + if ((unsigned char)*e >= 0x80) + return IDN2_ENCODING_ERROR; e++; + } - if (e - s > 4 && s[0] == 'x' && s[1] == 'n' && s[2] == '-' && s[3] == '-') { + if (e - s > 4 && (s[0] == 'x' || s[0] == 'X') && (s[1] == 'n' || s[1] == 'N') && s[2] == '-' && s[3] == '-') { size_t u32len = IDN2_LABEL_MAX_LENGTH * 4; uint32_t u32[IDN2_LABEL_MAX_LENGTH * 4]; uint8_t u8[IDN2_LABEL_MAX_LENGTH + 1]; -- cgit v1.2.1