changeset 769:cae5f15ca5ed

formats: Fix possible panic in PBG3 checksum check
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 30 Aug 2022 18:22:53 +0200
parents dbe2ddca4a8b
children f6c287745a67
files formats/src/th06/pbg3.rs
diffstat 1 files changed, 1 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/formats/src/th06/pbg3.rs
+++ b/formats/src/th06/pbg3.rs
@@ -145,8 +145,7 @@ impl<R: io::Read + io::Seek> PBG3<R> {
             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!"));