Verify endianess

This commit is contained in:
xavo95 2025-04-09 08:36:03 +07:00
parent 0ac751b29f
commit a668079894
Signed by: xavo95
GPG key ID: CBF8ADED6DEBB783

View file

@ -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 {