LibGfx/TIFF: Prevent the CCITT decoder to run on non bilevel image

This commit is contained in:
Lucas CHOLLET 2024-01-09 17:57:30 -05:00 committed by Andreas Kling
parent 0ef449a588
commit f6b86096a5
Notes: sideshowbarker 2024-07-17 02:22:23 +09:00

View file

@ -270,8 +270,12 @@ private:
break;
}
case Compression::CCITT: {
// Section 8: Baseline Field Reference Guide
// BitsPerSample must be 1, since this type of compression is defined only for bilevel images.
if (m_metadata.bits_per_sample()->size() > 1)
return Error::from_string_literal("TIFFImageDecoderPlugin: CCITT image with BitsPerSample greater than one, aborting...");
return Error::from_string_literal("TIFFImageDecoderPlugin: CCITT image with BitsPerSample greater than one");
if (m_metadata.photometric_interpretation() != PhotometricInterpretation::WhiteIsZero && m_metadata.photometric_interpretation() != PhotometricInterpretation::BlackIsZero)
return Error::from_string_literal("TIFFImageDecoderPlugin: CCITT compression is used on a non bilevel image");
ByteBuffer decoded_bytes {};
auto decode_ccitt_1D_strip = [&](u32 num_bytes) -> ErrorOr<ReadonlyBytes> {