Update handshake deserialize to error on wrong messages
This commit is contained in:
parent
5a12095959
commit
8b4f3afa42
1 changed files with 7 additions and 0 deletions
|
|
@ -524,6 +524,13 @@ impl Handshake<ByteBuf<'static>> {
|
|||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue