From f5b71b0c9fb1a3d498de3f02c8f3172db3d70129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20W=C3=BClker?= Date: Fri, 16 Feb 2024 15:15:00 +0100 Subject: [PATCH] graphics/image: Turn multiple bmp planes into a hard error Previously, we only emitted a warning but the spec explicitly states that this field should always be zero. --- crates/graphics/image/src/bmp.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/graphics/image/src/bmp.rs b/crates/graphics/image/src/bmp.rs index b9d06c91..a9f7de58 100644 --- a/crates/graphics/image/src/bmp.rs +++ b/crates/graphics/image/src/bmp.rs @@ -29,6 +29,7 @@ pub enum Error { PaletteTooLarge, NegativeWidth, InvalidCompressionForFormat, + MultiplePlanes, /// This image contains extreme values and cannot be parsed /// @@ -166,7 +167,8 @@ impl InfoHeader { .ok_or(Error::UnexpectedEndOfFile)?; if planes != 1 { - log::warn!("Unexpected number of planes, expected 1, got {planes:?}"); + log::error!("Unexpected number of planes, expected 1, got {planes:?}"); + return Err(Error::MultiplePlanes); } let bits_per_pixel = byte_stream