Skip to content

Commit

Permalink
LibGfx/TIFF: Reject images with an incoherent number of BitsPerSample
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasChollet authored and trflynn89 committed Mar 14, 2024
1 parent d15785c commit 06665cb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ class TIFFLoadingContext {
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 {};
}

Expand Down

0 comments on commit 06665cb

Please sign in to comment.