Remove potentially-failing unchecked arithmetic operations for ones which error

In response to 9.13.3.

Requires a bump to Rust 1.82 to take advantage of `Option::is_none_or`.
This commit is contained in:
Luke Parker
2025-08-08 22:30:34 -04:00
parent cbab9486c6
commit 188fcc3cb4
13 changed files with 65 additions and 18 deletions

View File

@@ -94,11 +94,10 @@ pub(crate) fn encode_check(mut data: Vec<u8>) -> String {
// Decode an arbitrary-length stream of data, with a checksum
pub(crate) fn decode_check(data: &str) -> Option<Vec<u8>> {
if data.len() < CHECKSUM_LEN {
let mut res = decode(data)?;
if res.len() < CHECKSUM_LEN {
None?;
}
let mut res = decode(data)?;
let checksum_pos = res.len() - CHECKSUM_LEN;
if keccak256(&res[.. checksum_pos])[.. CHECKSUM_LEN] != res[checksum_pos ..] {
None?;