Skip to content

Commit 96352c4

Browse files
authored
Merge pull request #2492 from swarnimarun/fix/properly-fail-for-planar-config-decode
fix: avoid panic multi planar tif images
2 parents 80b2124 + 5d01806 commit 96352c4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/codecs/tiff.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ where
5353
Err(other) => return Err(ImageError::from_tiff_decode(other)),
5454
};
5555

56+
let planar_config = inner
57+
.find_tag(tiff::tags::Tag::PlanarConfiguration)
58+
.map(|res| res.and_then(|r| r.into_u16().ok()).unwrap_or_default())
59+
.unwrap_or_default();
60+
61+
// Decode not supported for non Chunky Planar Configuration
62+
if planar_config > 1 {
63+
Err(ImageError::Unsupported(
64+
UnsupportedError::from_format_and_kind(
65+
ImageFormat::Tiff.into(),
66+
UnsupportedErrorKind::GenericFeature(String::from("PlanarConfiguration = 2")),
67+
),
68+
))?;
69+
}
70+
5671
let color_type = match tiff_color_type {
5772
tiff::ColorType::Gray(8) => ColorType::L8,
5873
tiff::ColorType::Gray(16) => ColorType::L16,

0 commit comments

Comments
 (0)