# HG changeset patch # User Emmanuel Gil Peyrot # Date 1661876573 -7200 # Node ID cae5f15ca5edbff38a0030a1d26a89ca27652963 # Parent dbe2ddca4a8b71e31a7d54a3c769ea446ec2577a formats: Fix possible panic in PBG3 checksum check diff --git a/formats/src/th06/pbg3.rs b/formats/src/th06/pbg3.rs --- a/formats/src/th06/pbg3.rs +++ b/formats/src/th06/pbg3.rs @@ -145,8 +145,7 @@ impl PBG3 { self.bitstream.seek(io::SeekFrom::Start(*offset as u64))?; let mut value: u32 = 0; for c in self.bitstream.read_bytes(compressed_size as usize)? { - value += c as u32; - value &= 0xffffffff; + value = value.wrapping_add(c as u32); } if value != *checksum { return Err(io::Error::new(io::ErrorKind::Other, "Corrupted data!"));