1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

LibGfx/TIFF: Move check on tag values in its own function

There is only one check for now, but the fuzzer has already found more
checks to add :^)
This commit is contained in:
Lucas CHOLLET 2023-12-30 00:13:54 -05:00 committed by Andrew Kaster
parent 6bc16ad62e
commit ba84af7c22

View file

@ -42,9 +42,18 @@ public:
return {};
}
ErrorOr<void> ensure_baseline_tags_correctness() const
{
if (m_metadata.strip_offsets()->size() != m_metadata.strip_byte_counts()->size())
return Error::from_string_literal("TIFFImageDecoderPlugin: StripsOffset and StripByteCount have different sizes");
return {};
}
ErrorOr<void> decode_frame()
{
TRY(ensure_baseline_tags_presence(m_metadata));
TRY(ensure_baseline_tags_correctness());
auto maybe_error = decode_frame_impl();
if (maybe_error.is_error()) {
@ -195,9 +204,6 @@ private:
auto const strips_offset = *m_metadata.strip_offsets();
auto const strip_byte_counts = *m_metadata.strip_byte_counts();
if (strips_offset.size() != strip_byte_counts.size())
return Error::from_string_literal("TIFFImageDecoderPlugin: StripsOffset and StripByteCount have different sizes, aborting...");
for (u32 strip_index = 0; strip_index < strips_offset.size(); ++strip_index) {
TRY(m_stream->seek(strips_offset[strip_index]));