* fix(rules): reject nan/inf and overflowing token lengths ParseTokens used ParseFloat and cast straight to int. Values like "nan", "inf" and "1e20" therefore became a huge negative (or other nonsensical) token threshold instead of an error. * fix(rules): reject tokens at the float64 MaxInt boundary float64(MaxInt) rounds to 2^63, so n > float64(MaxInt) let the boundary through and int(2^63) becomes MinInt on amd64.
16 lines
386 B
Go
16 lines
386 B
Go
package provider
|
|
|
|
import "testing"
|
|
|
|
func TestParseTokensRejectsNonFinite(t *testing.T) {
|
|
for _, in := range []string{
|
|
"nan", "NaN", "inf", "+inf", "1e20", "1e308", "1e20k",
|
|
"9223372036854775808", "9223372036854775k",
|
|
"9223372036854775807", // float64 rounds this to 2^63 on amd64
|
|
} {
|
|
if n, err := ParseTokens(in); err == nil {
|
|
t.Errorf("%q accepted as %d", in, n)
|
|
}
|
|
}
|
|
}
|