Verify endianess
This commit is contained in:
parent
0ac751b29f
commit
a668079894
1 changed files with 2 additions and 2 deletions
|
@ -170,7 +170,7 @@ impl KcpSegment {
|
||||||
#[cfg(feature = "kuro-crc")]
|
#[cfg(feature = "kuro-crc")]
|
||||||
if self.use_checksum {
|
if self.use_checksum {
|
||||||
let crc = crc32fast::hash(buf.iter().as_ref());
|
let crc = crc32fast::hash(buf.iter().as_ref());
|
||||||
buf.put_u32_le(crc); // Check correct endianness
|
buf.put_u32_le(crc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,7 +972,7 @@ impl<Output> Kcp<Output> {
|
||||||
cursor.read_exact(&mut sbuf)?;
|
cursor.read_exact(&mut sbuf)?;
|
||||||
let checksum = cursor.get_u32_le();
|
let checksum = cursor.get_u32_le();
|
||||||
cursor.set_position(backup);
|
cursor.set_position(backup);
|
||||||
let expected = crc32fast::hash(&sbuf).to_be();
|
let expected = crc32fast::hash(&sbuf);
|
||||||
if checksum == expected {
|
if checksum == expected {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue