mirror of
https://github.com/chatmail/core.git
synced 2026-10-18 10:53:07 +03:00
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:
+5
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user