Cannot read "artist" exif tag apparently containing trailing 0 bytes: plum._exceptions.ExcessMemoryError: unconsumed bytes
Hello,
I encountered a JPG-file in the wild that causes exif to throw an exception:
plum._exceptions.ExcessMemoryError: 24 unconsumed bytes
On investigation, this happens when my Python code calls getattr(image, "artist")
.
My understanding what is going on here, is: That "artist" string is longer than it would need to be,
and padded with trailing \0
characters.
Here is some traceback I get. I replaced a few characters with "X" or "x" to remove the names of people.
Traceback (most recent call last):
File "./downscale_selection", line 37, in <module>
value = getattr(big_image, exif_tag)
File "/home/andreas/XXX/Hochzeit/python-venv/lib/python3.7/site-packages/exif/_image.py", line 86, in __getattr__
return getattr(self._segments['APP1'], item)
File "/home/andreas/XXX/Hochzeit/python-venv/lib/python3.7/site-packages/exif/_app1_metadata.py", line 405, in __getattr__
return ifd_tag.read()
File "/home/andreas/XXX/Hochzeit/python-venv/lib/python3.7/site-packages/exif/ifd_tag/_ascii.py", line 84, in read
return AsciiZeroTermStr.unpack(value_bytes)
File "/home/andreas/XXX/Hochzeit/python-venv/lib/python3.7/site-packages/plum/_plum.py", line 243, in unpack
return unpack(cls, buffer)
File "/home/andreas/XXX/Hochzeit/python-venv/lib/python3.7/site-packages/plum/_plum.py", line 891, in unpack
unpack_and_dump(fmt, buffer)
File "/home/andreas/XXX/Hochzeit/python-venv/lib/python3.7/site-packages/plum/_plum.py", line 937, in unpack_and_dump
items, _offset = _unpack(fmt, buffer, 0, True, dump)
File "/home/andreas/XXX/Hochzeit/python-venv/lib/python3.7/site-packages/plum/_plum.py", line 852, in _unpack
raise UnpackError(unexpected_exception)
plum._exceptions.UnpackError:
+--------+-----------------+----------------+-------------------------------------------------+------------------+
| Offset | Access | Value | Bytes | Type |
+--------+-----------------+----------------+-------------------------------------------------+------------------+
| | | | | AsciiZeroTermStr |
| 0 | [0:12] | 'XXXXX XXXXXXX' | xx xx xx xx 20 xx xx xx xx xx xx xx | |
| 12 | --termination-- | | 00 | |
+--------+-----------------+----------------+-------------------------------------------------+------------------+
| 13 | | <excess bytes> | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
| 29 | | | 00 00 00 00 00 00 00 00 | |
+--------+-----------------+----------------+-------------------------------------------------+------------------+
ExcessMemoryError occurred during unpack operation:
24 unconsumed bytes