p2p/enr: check size limit when decoding

This commit is contained in:
Felix Lange 2017-12-07 12:31:26 +01:00
parent 617f9e64f8
commit 67301a1c23

View file

@ -33,11 +33,7 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
const (
// SizeLimit is the maximum encoded size of a node record in bytes.
// Implementations should reject records larger than this size.
SizeLimit = 300
)
const SizeLimit = 300 // maximum encoded size of a node record in bytes
var (
errNoID = errors.New("unknown or unspecified identity scheme")
@ -140,6 +136,9 @@ func (r *Record) DecodeRLP(s *rlp.Stream) error {
if err != nil {
return err
}
if len(raw) > SizeLimit {
return errTooBig
}
// Decode the RLP container.
dec := Record{raw: raw}