mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
p2p/enr: check size limit when decoding
This commit is contained in:
parent
617f9e64f8
commit
67301a1c23
1 changed files with 4 additions and 5 deletions
|
|
@ -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}
|
||||
|
|
|
|||
Loading…
Reference in a new issue