From d84eb9d93c718d8d98b02a2f73adb38ead4271c3 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 21 Dec 2022 14:41:14 +0100 Subject: [PATCH] fix(net): add capacity check on ping (#558) --- crates/net/eth-wire/src/p2pstream.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/net/eth-wire/src/p2pstream.rs b/crates/net/eth-wire/src/p2pstream.rs index 1fe45c803e..c21db5fdc7 100644 --- a/crates/net/eth-wire/src/p2pstream.rs +++ b/crates/net/eth-wire/src/p2pstream.rs @@ -339,6 +339,10 @@ where let id = *bytes.first().ok_or(P2PStreamError::EmptyProtocolMessage)?; match id { _ if id == P2PMessageID::Ping as u8 => { + if this.outgoing_messages.len() > MAX_P2P_CAPACITY { + return Poll::Ready(Some(Err(P2PStreamError::SendBufferFull))) + } + tracing::trace!("Received Ping, Sending Pong"); this.send_pong(); }