Skip to content

Commit 40709f9

Browse files
author
Rusty Rain
authored
Merge pull request #7 from legion-labs/main
Moved checksum check sooner in the parsing for faster failures
2 parents 270208a + 0c9a897 commit 40709f9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/sctp/src/packet.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ impl Packet {
9393
let destination_port = reader.get_u16();
9494
let verification_tag = reader.get_u32();
9595
let their_checksum = reader.get_u32_le();
96+
let our_checksum = generate_packet_checksum(raw);
97+
98+
if their_checksum != our_checksum {
99+
return Err(Error::ErrChecksumMismatch.into());
100+
}
96101

97102
let mut chunks = vec![];
98103
let mut offset = PACKET_HEADER_SIZE;
@@ -130,11 +135,6 @@ impl Packet {
130135
chunks.push(c);
131136
}
132137

133-
let our_checksum = generate_packet_checksum(raw);
134-
if their_checksum != our_checksum {
135-
return Err(Error::ErrChecksumMismatch.into());
136-
}
137-
138138
Ok(Packet {
139139
source_port,
140140
destination_port,

0 commit comments

Comments
 (0)