mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +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"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const SizeLimit = 300 // maximum encoded size of a node record in bytes
|
||||||
// SizeLimit is the maximum encoded size of a node record in bytes.
|
|
||||||
// Implementations should reject records larger than this size.
|
|
||||||
SizeLimit = 300
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errNoID = errors.New("unknown or unspecified identity scheme")
|
errNoID = errors.New("unknown or unspecified identity scheme")
|
||||||
|
|
@ -140,6 +136,9 @@ func (r *Record) DecodeRLP(s *rlp.Stream) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if len(raw) > SizeLimit {
|
||||||
|
return errTooBig
|
||||||
|
}
|
||||||
|
|
||||||
// Decode the RLP container.
|
// Decode the RLP container.
|
||||||
dec := Record{raw: raw}
|
dec := Record{raw: raw}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue