Browse Source

set max msg size

otherwise, it is easy to get OutOfMemory panic (somebody can even expoit
this)
pull/965/head
Anton Kaliaev 7 years ago
parent
commit
ee66476d62
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      consensus/wal.go

+ 8
- 0
consensus/wal.go 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 {


Loading…
Cancel
Save