Skip to content

Commit ba84af7

Browse files
LucasCholletADKaster
authored andcommitted
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 :^)
1 parent 6bc16ad commit ba84af7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,18 @@ class TIFFLoadingContext {
4242
return {};
4343
}
4444

45+
ErrorOr<void> ensure_baseline_tags_correctness() const
46+
{
47+
if (m_metadata.strip_offsets()->size() != m_metadata.strip_byte_counts()->size())
48+
return Error::from_string_literal("TIFFImageDecoderPlugin: StripsOffset and StripByteCount have different sizes");
49+
50+
return {};
51+
}
52+
4553
ErrorOr<void> decode_frame()
4654
{
4755
TRY(ensure_baseline_tags_presence(m_metadata));
56+
TRY(ensure_baseline_tags_correctness());
4857
auto maybe_error = decode_frame_impl();
4958

5059
if (maybe_error.is_error()) {
@@ -195,9 +204,6 @@ class TIFFLoadingContext {
195204
auto const strips_offset = *m_metadata.strip_offsets();
196205
auto const strip_byte_counts = *m_metadata.strip_byte_counts();
197206

198-
if (strips_offset.size() != strip_byte_counts.size())
199-
return Error::from_string_literal("TIFFImageDecoderPlugin: StripsOffset and StripByteCount have different sizes, aborting...");
200-
201207
for (u32 strip_index = 0; strip_index < strips_offset.size(); ++strip_index) {
202208
TRY(m_stream->seek(strips_offset[strip_index]));
203209

0 commit comments

Comments
 (0)