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

@@ -343,7 +343,13 @@ impl RctPrunable {
Ok(match rct_type {
RctType::AggregateMlsagBorromean => RctPrunable::AggregateMlsagBorromean {
borromean: read_raw_vec(BorromeanRange::read, outputs, r)?,
mlsag: Mlsag::read(ring_length, inputs + 1, r)?,
mlsag: Mlsag::read(
ring_length,
inputs.checked_add(1).ok_or_else(|| {
io::Error::other("reading a MLSAG for more inputs than representable")
})?,
r,
)?,
},
RctType::MlsagBorromean => RctPrunable::MlsagBorromean {
borromean: read_raw_vec(BorromeanRange::read, outputs, r)?,