mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 01:41:31 +00:00
Fix bug in merkle/iavl_proof; TODO maybe read zero length slices as nil?
This commit is contained in:
@ -2,6 +2,8 @@ package binary
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
)
|
||||
|
||||
func WriteByteSlice(bz []byte, w io.Writer, n *int64, err *error) {
|
||||
@ -14,8 +16,12 @@ func ReadByteSlice(r io.Reader, n *int64, err *error) []byte {
|
||||
if *err != nil {
|
||||
return nil
|
||||
}
|
||||
if MaxBinaryReadSize < *n+int64(length) {
|
||||
*err = ErrMaxBinaryReadSizeReached
|
||||
if length < 0 {
|
||||
*err = ErrBinaryReadSizeUnderflow
|
||||
return nil
|
||||
}
|
||||
if MaxBinaryReadSize < MaxInt64(int64(length), *n+int64(length)) {
|
||||
*err = ErrBinaryReadSizeOverflow
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -41,8 +47,12 @@ func ReadByteSlices(r io.Reader, n *int64, err *error) [][]byte {
|
||||
if *err != nil {
|
||||
return nil
|
||||
}
|
||||
if MaxBinaryReadSize < *n+int64(length) {
|
||||
*err = ErrMaxBinaryReadSizeReached
|
||||
if length < 0 {
|
||||
*err = ErrBinaryReadSizeUnderflow
|
||||
return nil
|
||||
}
|
||||
if MaxBinaryReadSize < MaxInt64(int64(length), *n+int64(length)) {
|
||||
*err = ErrBinaryReadSizeOverflow
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user