diff --git a/src/idna.c b/src/idna.c index 4638546d..efc5f283 100644 --- a/src/idna.c +++ b/src/idna.c @@ -322,6 +322,9 @@ ssize_t uv__idna_toascii(const char* s, const char* se, char* d, char* de) { char* ds; int rc; + if (s == se) + return UV_EINVAL; + ds = d; si = s; diff --git a/test/test-idna.c b/test/test-idna.c index 5f8d696a..3c4820f7 100644 --- a/test/test-idna.c +++ b/test/test-idna.c @@ -115,6 +115,7 @@ TEST_IMPL(utf8_decode1_overrun) { ASSERT_PTR_EQ(p, b + 1); b[0] = 0x7F; + ASSERT_EQ(UV_EINVAL, uv__idna_toascii(b, b + 0, c, c + 1)); ASSERT_EQ(UV_EINVAL, uv__idna_toascii(b, b + 1, c, c + 1)); return 0;