mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-10 18:16:39 +00:00
p2p/discover: copy buffer before sending read errors to unhandled (#34888)
This fixes an issue where packets send to the `Unhandled` channel configured on discv4 could be corrupted when the packet buffer gets reused. --------- Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
f7b7d4c7e5
commit
e1e3eaa381
1 changed files with 2 additions and 1 deletions
|
|
@ -555,8 +555,9 @@ func (t *UDPv4) readLoop(unhandled chan<- ReadPacket) {
|
||||||
if err := t.handlePacket(from, buf[:nbytes]); err != nil && unhandled == nil {
|
if err := t.handlePacket(from, buf[:nbytes]); err != nil && unhandled == nil {
|
||||||
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
|
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
|
||||||
} else if err != nil && unhandled != nil {
|
} else if err != nil && unhandled != nil {
|
||||||
|
p := ReadPacket{bytes.Clone(buf[:nbytes]), from}
|
||||||
select {
|
select {
|
||||||
case unhandled <- ReadPacket{buf[:nbytes], from}:
|
case unhandled <- p:
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue