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

Some images can crash ged2doc #24

Closed
andy-z opened this issue Sep 6, 2018 · 5 comments
Closed

Some images can crash ged2doc #24

andy-z opened this issue Sep 6, 2018 · 5 comments

Comments

@andy-z
Copy link
Owner

andy-z commented Sep 6, 2018

  • GEDCOM Utilities version: 0.1.15
  • Python version:
  • Operating System: Windows

Description

ged2doc crash has been reported here: https://genery.com/ru/forum/viewtopic.php?f=11&t=4194&start=90#p21681

Apparently some images can cause grief in PIL (pillow) which raises exception which crashes ged2doc.

@andy-z
Copy link
Owner Author

andy-z commented Sep 6, 2018

Managed to get a copy of an image from user, it is indeed causing PIL/pillow to do nasty exceptions on WIndows.

Here is a simple Python prompt trying to do the same thing as ged2doc:

(venv-win-py36) PS M:\> python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> Image.open('zolotaya-svadba-046.JPG')
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 1441814 bytes but only got 0. Skipping tag 33
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 428 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 196608 bytes but only got 0. Skipping tag 60
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 196608 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 524288 bytes but only got 0. Skipping tag 240
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 1048576 bytes but only got 0. Skipping tag 13222
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 2097152 bytes but only got 0. Skipping tag 1860
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 458752 bytes but only got 0. Skipping tag 10869
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 458752 bytes but only got 0. Skipping tag 1821
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 393216 bytes but only got 0. Skipping tag 1024
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 786432 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 1572864 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 33752069 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "M:\venv-win-py36\lib\site-packages\PIL\Image.py", line 2577, in open
    im = _open_core(fp, filename, prefix)
  File "M:\venv-win-py36\lib\site-packages\PIL\Image.py", line 2567, in _open_core
    im = factory(fp, filename)
  File "M:\venv-win-py36\lib\site-packages\PIL\JpegImagePlugin.py", line 779, in jpeg_factory
    im = JpegImageFile(fp, filename)
  File "M:\venv-win-py36\lib\site-packages\PIL\ImageFile.py", line 102, in __init__
    self._open()
  File "M:\venv-win-py36\lib\site-packages\PIL\JpegImagePlugin.py", line 338, in _open
    handler(self, i)
  File "M:\venv-win-py36\lib\site-packages\PIL\JpegImagePlugin.py", line 123, in APP
    exif = self._getexif()
  File "M:\venv-win-py36\lib\site-packages\PIL\JpegImagePlugin.py", line 431, in _getexif
    return _getexif(self)
  File "M:\venv-win-py36\lib\site-packages\PIL\JpegImagePlugin.py", line 466, in _getexif
    info.load(file)
  File "M:\venv-win-py36\lib\site-packages\PIL\TiffImagePlugin.py", line 730, in load
    fp.seek(offset)
OverflowError: Python int too large to convert to C ssize_t

Same image on Linux does not crash but still makes bunch of warnings

Python 3.6.3 (default, Oct  3 2017, 21:45:48)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
>>> img = Image.open('zolotaya-svadba-046.JPG')
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 1441814 bytes but only got 0. Skipping tag 33
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 428 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 196608 bytes but only got 0. Skipping tag 60
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 196608 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 524288 bytes but only got 0. Skipping tag 240
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 1048576 bytes but only got 0. Skipping tag 13222
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 2097152 bytes but only got 0. Skipping tag 1860
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 458752 bytes but only got 0. Skipping tag 10869
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 458752 bytes but only got 0. Skipping tag 1821
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 393216 bytes but only got 0. Skipping tag 1024
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 786432 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 1572864 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 33752069 bytes but only got 0. Skipping tag 0
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 24113876360 bytes but only got 0. Skipping tag 30719
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 30889119128 bytes but only got 0. Skipping tag 62463
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 238688098 bytes but only got 0. Skipping tag 63316
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 282 bytes but only got 0. Skipping tag 1
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:739: UserWarning: Possibly corrupt EXIF data.  Expecting to read 513 bytes but only got 0. Skipping tag 1
  " Skipping tag %s" % (size, len(data), tag))
/home/salnikov/venv-3.6/lib/python3.6/site-packages/PIL/TiffImagePlugin.py:756: UserWarning: Corrupt EXIF data.  Expecting to read 12 bytes but only got 4.
  warnings.warn(str(msg))

Difference is probably related to 32-bit Python on Windows and 64-bit Python on Linux

@andy-z
Copy link
Owner Author

andy-z commented Sep 6, 2018

Couple more things:

  • On both Linux and Windows pillow is at version 5.1.0. Want to check whether there is a newer version which fixes the issue.
  • would be nice to have reproducible test case for this bu I'm not sure I can create a smaller JPEG file with corrupted EXIF data

@andy-z
Copy link
Owner Author

andy-z commented Sep 6, 2018

pillow 5.2.0 is the most recent version. Tried to install it on Windows, still the same exception happens.

@andy-z
Copy link
Owner Author

andy-z commented Sep 7, 2018

Opened a ticket for pillow: python-pillow/Pillow#3337

@andy-z
Copy link
Owner Author

andy-z commented Jul 6, 2020

Fixed in Pillow.

@andy-z andy-z closed this as completed Jul 6, 2020
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

No branches or pull requests

1 participant