Avoid rune overflow when converting to unicode

This commit is contained in:
Rafael Dantas Justo 2015-08-10 08:57:07 -03:00
parent e220dd92fd
commit 7ed808b59f
2 changed files with 5 additions and 1 deletions

View File

@ -254,6 +254,10 @@ func decode(b []byte) []byte {
return src return src
} }
i += digit * w i += digit * w
if i < 0 {
// safety check for rune overflow
return src
}
t = tfunc(k, bias) t = tfunc(k, bias)
if digit < t { if digit < t {

View File

@ -86,7 +86,7 @@ var invalidACEs = []string{
"xn--*", "xn--*",
"xn--", "xn--",
"xn---", "xn---",
//"xn--a000000000", // crashes IDN. TODO(miek): Fix. "xn--a000000000",
} }
func TestInvalidPunycode(t *testing.T) { func TestInvalidPunycode(t *testing.T) {