diff --git a/crates/peer_binary_protocol/src/lib.rs b/crates/peer_binary_protocol/src/lib.rs index 97e6dcc..2a5f09b 100644 --- a/crates/peer_binary_protocol/src/lib.rs +++ b/crates/peer_binary_protocol/src/lib.rs @@ -524,6 +524,13 @@ impl Handshake> { let pstr_len = *b .first() .ok_or(MessageDeserializeError::NotEnoughData(1, "handshake"))?; + if pstr_len as usize != PSTR_BT1.len() { + return Err(MessageDeserializeError::Other(anyhow::anyhow!( + "pstr should be {} bytes long, but received {}", + PSTR_BT1.len(), + pstr_len + ))); + } let expected_len = 1usize + pstr_len as usize + 48; let hbuf = b .get(..expected_len)