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`.
This commit is contained in:
link2xt
2026-10-12 19:05:20 +00:00
parent 036b928a7f
commit 67bf4e3d5d
+5 -2
View File
@@ -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