LibGfx/TIFF: Reject images with an incoherent number of BitsPerSample

Fixes oss-fuzz issue 66588:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66588
This commit is contained in:
Lucas CHOLLET 2024-03-08 14:46:09 -05:00 committed by Tim Flynn
parent d15785cccc
commit 06665cba9c
Notes: sideshowbarker 2024-07-18 22:57:59 +09:00

View File

@ -106,6 +106,12 @@ public:
if (any_of(*m_metadata.bits_per_sample(), [](auto bit_depth) { return bit_depth == 0 || bit_depth > 32; }))
return Error::from_string_literal("TIFFImageDecoderPlugin: Invalid value in BitsPerSample");
if (m_metadata.bits_per_sample()->size() != m_metadata.samples_per_pixel())
return Error::from_string_literal("TIFFImageDecoderPlugin: Invalid number of values in BitsPerSample");
if (*m_metadata.samples_per_pixel() < samples_for_photometric_interpretation())
return Error::from_string_literal("TIFFImageDecoderPlugin: Not enough values in BitsPerSample for given PhotometricInterpretation");
return {};
}