rich7420 opened a new pull request, #1324: URL: https://github.com/apache/mahout/pull/1324
## Summary - `Preprocessor::validate_batch` and `AmplitudeEncoder::encode_batch_f32` computed `num_samples * sample_size` without overflow checks. The angle encoder paths already use `checked_mul` (angle.rs:87, :143, :327, :405, :528) — these two sites were missed. - On 64-bit hosts the product can wrap, letting an undersized buffer pass the length check and causing out-of-bounds reads downstream in the encoder. - This PR mirrors the angle.rs pattern: `checked_mul` returning `MahoutError::InvalidInput` on overflow. ## Changes - `qdp/qdp-core/src/preprocessing.rs`: guard `num_samples * sample_size` in `validate_batch`. - `qdp/qdp-core/src/gpu/encodings/amplitude.rs`: guard the same multiplication in `encode_batch_f32` (the f64 path already routes through `Preprocessor::validate_batch`). - Added a unit test in `preprocessing.rs` covering the overflow path. ## Test plan - [x] `cargo test --manifest-path qdp/qdp-core/Cargo.toml --lib` — 77 passed, 0 failed - [x] pre-commit (clippy, rustfmt, license headers) — all pass - [x] New test `validate_batch_rejects_size_overflow` exercises the `checked_mul` failure branch -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
