Skip to content

Fix TypeError on thumbnail tags with malformed values - #260

Open
devmaiter wants to merge 1 commit into
ianare:developfrom
devmaiter:fix-247-invalid-thumbnail-offset
Open

Fix TypeError on thumbnail tags with malformed values#260
devmaiter wants to merge 1 commit into
ianare:developfrom
devmaiter:fix-247-invalid-thumbnail-offset

Conversation

@devmaiter

Copy link
Copy Markdown

Fixes #247

A crafted file can declare Thumbnail JPEGInterchangeFormat (or the length tag, or the MakerNote thumbnail tag) with a field type it should not have — a float decodes to a tuple — and extract_jpeg_thumbnail() crashed with TypeError: unsupported operand type(s) for +: 'int' and 'tuple', which escapes process_file().

The offset and length values are now validated before use: when a value is missing, negative or not an integer, a warning is logged and thumbnail extraction is skipped, while the remaining tags are still returned. Includes a synthetic sample based on the PoC from the issue and a regression test.

A crafted file can declare the thumbnail offset or length tags with a
non-integer field type, crashing extract_jpeg_thumbnail() with
TypeError when the decoded value is a tuple. Validate the values
before use and skip thumbnail extraction, keeping the remaining tags.

Add a synthetic sample image reproducing the float offset case from
the report, with a regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant