mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 22:44:24 +00:00
p2p: set RecvMessageCapacity to maxMsgSize in all reactors
to prevent malicious nodes from sending us large messages (~21MB, which is the default `RecvMessageCapacity`) This allows us to remove unnecessary `maxMsgSize` check in `decodeMsg`. Since each channel has a msg capacity set to `maxMsgSize`, there's no need to check it again in `decodeMsg`. Closes #1503
This commit is contained in:
+4
-6
@@ -137,10 +137,12 @@ func (memR *Reactor) OnStart() error {
|
||||
// GetChannels implements Reactor.
|
||||
// It returns the list of channels for this reactor.
|
||||
func (memR *Reactor) GetChannels() []*p2p.ChannelDescriptor {
|
||||
maxMsgSize := calcMaxMsgSize(memR.config.MaxTxBytes)
|
||||
return []*p2p.ChannelDescriptor{
|
||||
{
|
||||
ID: MempoolChannel,
|
||||
Priority: 5,
|
||||
ID: MempoolChannel,
|
||||
Priority: 5,
|
||||
RecvMessageCapacity: maxMsgSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -271,10 +273,6 @@ func RegisterMessages(cdc *amino.Codec) {
|
||||
}
|
||||
|
||||
func (memR *Reactor) decodeMsg(bz []byte) (msg Message, err error) {
|
||||
maxMsgSize := calcMaxMsgSize(memR.config.MaxTxBytes)
|
||||
if l := len(bz); l > maxMsgSize {
|
||||
return msg, ErrTxTooLarge{maxMsgSize, l}
|
||||
}
|
||||
err = cdc.UnmarshalBinaryBare(bz, &msg)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user