diff options
author | Felix Lange <fjl@twurst.com> | 2015-07-18 22:13:20 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-07-18 22:23:35 +0800 |
commit | 345590f27f81517fd7b560a3fafb0a2c8b498094 (patch) | |
tree | 687cb53f92cf769df36aa3bf79eb40dadcc1730a /rlp/decode.go | |
parent | cefd948267c6d16b317f7c15feb653a7725a3f1b (diff) | |
download | go-tangerine-345590f27f81517fd7b560a3fafb0a2c8b498094.tar go-tangerine-345590f27f81517fd7b560a3fafb0a2c8b498094.tar.gz go-tangerine-345590f27f81517fd7b560a3fafb0a2c8b498094.tar.bz2 go-tangerine-345590f27f81517fd7b560a3fafb0a2c8b498094.tar.lz go-tangerine-345590f27f81517fd7b560a3fafb0a2c8b498094.tar.xz go-tangerine-345590f27f81517fd7b560a3fafb0a2c8b498094.tar.zst go-tangerine-345590f27f81517fd7b560a3fafb0a2c8b498094.zip |
rlp: fix check for canonical byte array size
Decoding did not reject byte arrays of length one with a single element
b where 55 < b < 128. Such byte arrays must be rejected because
they must be encoded as the single byte b instead.
Diffstat (limited to 'rlp/decode.go')
-rw-r--r-- | rlp/decode.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/rlp/decode.go b/rlp/decode.go index f17690522..cc402fc94 100644 --- a/rlp/decode.go +++ b/rlp/decode.go @@ -361,7 +361,7 @@ func decodeByteArray(s *Stream, val reflect.Value) error { return err } // Reject cases where single byte encoding should have been used. - if size == 1 && slice[0] < 56 { + if size == 1 && slice[0] < 128 { return wrapStreamError(ErrCanonSize, val.Type()) } case List: @@ -623,7 +623,7 @@ func (s *Stream) Bytes() ([]byte, error) { if err = s.readFull(b); err != nil { return nil, err } - if size == 1 && b[0] < 56 { + if size == 1 && b[0] < 128 { return nil, ErrCanonSize } return b, nil @@ -687,7 +687,7 @@ func (s *Stream) uint(maxbits int) (uint64, error) { return 0, ErrCanonInt case err != nil: return 0, err - case size > 0 && v < 56: + case size > 0 && v < 128: return 0, ErrCanonSize default: return v, nil |