aboutsummaryrefslogtreecommitdiffstats
path: root/rlp/decode.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-07-18 22:13:20 +0800
committerFelix Lange <fjl@twurst.com>2015-07-18 22:23:35 +0800
commit345590f27f81517fd7b560a3fafb0a2c8b498094 (patch)
tree687cb53f92cf769df36aa3bf79eb40dadcc1730a /rlp/decode.go
parentcefd948267c6d16b317f7c15feb653a7725a3f1b (diff)
downloadgo-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.go6
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