Skip to content

Commit

Permalink
Assert correct length for array in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
immanelg committed Jan 16, 2024
1 parent 72d1518 commit 3639afb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion memcrab-protocol/src/transport/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ where
RequestFlag::Version => {
let version_bytes = &header_chunk[..RequestHeader::version_size()];
let version = Version::from_be_bytes(
version_bytes.try_into().map_err(|_| ParsingError::Header)?,
version_bytes
.try_into()
.expect("version_bytes should have the length of version_size()"),
);
Ok(RequestHeader::Version(version))
}
Expand Down

0 comments on commit 3639afb

Please sign in to comment.