func parseBase128Int(bytes []byte, initOffset int) (ret, offset int, err error) {
offset = initOffset
for shifted := 0; offset < len(bytes); shifted++ {
- if shifted > 4 {
+ if shifted == 4 {
err = StructuralError{"base 128 integer too large"}
return
}
{[]byte{0xa0, 0x84, 0x80, 0x00, 0x00, 0x00}, false, tagAndLength{}},
// Long length form may not be used for lengths that fit in short form.
{[]byte{0xa0, 0x81, 0x7f}, false, tagAndLength{}},
+ // Tag numbers which would overflow int32 are rejected. (The value below is 2^31.)
+ {[]byte{0x1f, 0x88, 0x80, 0x80, 0x80, 0x00, 0x00}, false, tagAndLength{}},
}
func TestParseTagAndLength(t *testing.T) {