Skip to content

Commit

Permalink
Use stack memory when sending UDP data.
Browse files Browse the repository at this point in the history
When handling ESP packets, use the real encrypted packet size instead
of just contents+signature.
  • Loading branch information
zlogic committed Dec 11, 2024
1 parent 753a2d6 commit b03eb9a
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 174 deletions.
4 changes: 2 additions & 2 deletions src/ikev2/esp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ impl SecurityAssociation {
data: &'a mut [u8],
msg_len: usize,
) -> Result<&'a [u8], EspError> {
if data.len() < msg_len + 8 + self.signature_length {
return Err("Not enough data in ESP packet".into());
if data.len() < self.encoded_length(msg_len) {
return Err("Not enough capacity in ESP packet buffer".into());
}
if self.local_seq == u32::MAX {
return Err("Sequence number overflow".into());
Expand Down
Loading

0 comments on commit b03eb9a

Please sign in to comment.