diff options
author | Ashelyn Rose <git@ashen.earth> | 2024-12-24 17:42:41 -0700 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-12-24 17:42:41 -0700 |
commit | 77c2625a52c18f3364fe6b91b7466aaaa3d9aac3 (patch) | |
tree | 440bcb3eb00bbc1b3f80da2a7df3209576618efa /src/main.rs | |
parent | ced4757324d0eac5a26f14da7de4abc875019af1 (diff) |
Fix overflow in checksum
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 3aeb2e7..5b44958 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,8 @@ fn main() { .array_chunks::<4>() .map(|bytes| u32::from_be_bytes(bytes)) // Subtract expected as we're supposed to compute it with that blanked - .fold(0u32, |a,b| a.overflowing_add(b).0) - exp_checksum; + .fold(0u32, |a,b| a.overflowing_add(b).0) + .overflowing_sub(exp_checksum).0; if file_data.len() % 4 != 0 { panic!("Invalid checksum: Uneven number of bytes"); |