summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-01-26 13:21:39 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-01-26 15:42:14 +0100
commitc88b60342854d0f8c08de5e3fde2d964a422c386 (patch)
tree54dac22cefa40385608da36ae5ec51eca6aabb3d
parentde97c3d74bf770c3368333a399085e2e53b99026 (diff)
downloadgnutls-c88b60342854d0f8c08de5e3fde2d964a422c386.tar.gz
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 <nmav@redhat.com>
-rw-r--r--lib/str-idna.c7
1 files 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];