mirror of
https://github.com/vladtrc/iw4L
synced 2026-10-26 10:19:50 -04:00
Merge pull request #26 from gitoutofthere/fix/snapshot-delta-length
Check a snapshot delta's length against its frame before allocating it
This commit is contained in:
@@ -29,6 +29,9 @@ impl SnapshotDelta {
|
||||
pub fn decode(input: &mut WireReader<'_>) -> Result<Self, WireError> {
|
||||
let tick = Tick(input.get_u32()?);
|
||||
let length = input.get_u32()? as usize;
|
||||
if length > input.remaining() {
|
||||
return Err(WireError::Malformed("snapshot delta longer than its frame"));
|
||||
}
|
||||
let mut bytes = vec![0u8; length];
|
||||
input.get_bytes(&mut bytes)?;
|
||||
Ok(Self { tick, bytes })
|
||||
|
||||
Reference in New Issue
Block a user