summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Rühsen <tim.ruehsen@gmx.de>2019-01-22 08:02:32 +0000
committerTim Rühsen <tim.ruehsen@gmx.de>2019-01-22 08:02:32 +0000
commit5fb3a45e34a843942f0fe55d55779111d7f18eaa (patch)
treed6b811b3921b01a77ccfdd2a1a7d7686920325b8
parent69bd75e39d0ddd4e86630facf38e7bf3186f3b06 (diff)
parent78424e4645f69d8ffe9421096630db6038980949 (diff)
downloadgnutls-5fb3a45e34a843942f0fe55d55779111d7f18eaa.tar.gz
Merge branch 'tmp-fix-fuzzer-timeout' into 'master'
Avoid excessive CPU usage in gnutls_idna_map() See merge request gnutls/gnutls!881
-rw-r--r--lib/str-idna.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/str-idna.c b/lib/str-idna.c
index 30a09407c0..4f275aebfb 100644
--- a/lib/str-idna.c
+++ b/lib/str-idna.c
@@ -81,6 +81,14 @@ int gnutls_idna_map(const char *input, unsigned ilen, gnutls_datum_t *out, unsig
idn2_tflags |= IDN2_TRANSITIONAL;
#endif
+ /* This avoids excessive CPU usage with libidn2 < 2.1.1 */
+ if (ilen > 2048) {
+ gnutls_assert();
+ _gnutls_debug_log("unable to convert name '%.*s' to IDNA format: %s\n",
+ (int) ilen, input, idn2_strerror(IDN2_TOO_BIG_DOMAIN));
+ return GNUTLS_E_INVALID_UTF8_STRING;
+ }
+
if (ilen == 0) {
out->data = (uint8_t*)gnutls_strdup("");
out->size = 0;