From 67bf4e3d5da4e7051f7fb65768f09435bc9bff01 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 12 Oct 2026 19:01:08 +0000 Subject: [PATCH] fix: avoid integer overflow when multiplying received image width by height This is a minor fix, worst case an image with very large dimensions will not be classified as a File. Mostly removing `clippy::arithmetic_side_effects`. --- src/mimeparser.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 6f712da06..026d8f6c7 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -1490,7 +1490,6 @@ impl MimeMessage { } #[expect(clippy::too_many_arguments)] - #[expect(clippy::arithmetic_side_effects)] async fn do_add_single_file_part( &mut self, context: &Context, @@ -1565,7 +1564,11 @@ impl MimeMessage { { match get_filemeta(decoded_data) { // image size is known, not too big, keep msg_type: - Ok((width, height)) if width * height <= constants::MAX_RCVD_IMAGE_PIXELS => { + Ok((width, height)) + if width + .checked_mul(height) + .is_some_and(|pixels| pixels <= constants::MAX_RCVD_IMAGE_PIXELS) => + { part.param.set_i64(Param::Width, width.into()); part.param.set_i64(Param::Height, height.into()); msg_type