Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch struct.error from truncated EXIF when reading JPEG DPI #7458

Merged
merged 1 commit into from Oct 13, 2023

Conversation

radarhere
Copy link
Member

Resolves #7456

The image in the issue raises a UnidentifiedImageError. Hiding behind that is the following traceback when attempting to read DPI from JPEG EXIF.

Traceback (most recent call last):
  File "PIL/ImageFile.py", line 117, in __init__
  File "PIL/JpegImagePlugin.py", line 382, in _open
  File "PIL/JpegImagePlugin.py", line 160, in APP
  File "PIL/Image.py", line 1441, in getexif
  File "PIL/Image.py", line 3730, in load
  File "PIL/TiffImagePlugin.py", line 526, in __init__
  File "PIL/TiffImagePlugin.py", line 670, in _unpack
struct.error: unpack requires a buffer of 4 bytes

This PR adds struct.error to the list of exceptions caught, to handle this truncated data. The test image comes from the issue.

@hugovk hugovk merged commit ff37a5b into python-pillow:main Oct 13, 2023
53 checks passed
@radarhere radarhere deleted the truncated_exif branch October 13, 2023 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Malformed APP1 EXIF segment are not ignored
2 participants