set max msg size

otherwise, it is easy to get OutOfMemory panic (somebody can even expoit
this)
This commit is contained in:
Anton Kaliaev 2017-12-11 19:48:57 -06:00
parent 40f9261d48
commit ee66476d62
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with 8 additions and 0 deletions

View File

@ -17,6 +17,10 @@ import (
cmn "github.com/tendermint/tmlibs/common"
)
const (
maxMsgSizeBytes = 10024 // 10MB
)
//--------------------------------------------------------
// types and functions for savings consensus messages
@ -272,6 +276,10 @@ func (dec *WALDecoder) Decode() (*TimedWALMessage, error) {
}
length := binary.BigEndian.Uint32(b)
if length > maxMsgSizeBytes {
return nil, DataCorruptionError{fmt.Errorf("length %d exceeded maximum possible value %d", length, maxMsgSizeBytes)}
}
data := make([]byte, length)
n, err = dec.rd.Read(data)
if err == io.EOF {