1. Fredrik Lundh
  2. pil-2009-raclette
  3. Issues
Issue #24 new

saferead breaks exif parsing

Anonymous created an issue

Commit [[http://hg.effbot.org/pil-2009-raclette/changeset/9fd147468c93|9fd147468c93]] breaks exif parsing as fp in ImageFileDirectory.load(fp) is a StrinIO (see JpegImagePlugin:376-381). The following patch fixes the issue (however, i don't know if this happens in other places as well):

{{{ --- TiffImagePlugin.py 2012-07-05 10:28:37.320810000 +0200 +++ TiffImagePlugin_orig.py 2012-07-05 10:28:28.912882000 +0200 @@ -377,7 +377,7 @@ if size > 4: here = fp.tell() fp.seek(i32(ifd, 8)) - data = fp.read(size) + data = fp.saferead(size) fp.seek(here) else: data = ifd[8:8+size] }}}

Best, Lukas

Comments (1)

  1. Anonymous

    Uh, mixed up the patch. Here we go in the right order:

    --- TiffImagePlugin_orig.py	2012-07-05 10:28:28.912882000 +0200
    +++ TiffImagePlugin.py	2012-07-05 10:28:37.320810000 +0200
    @@ -377,7 +377,7 @@
                 if size > 4:
                     here = fp.tell()
                     fp.seek(i32(ifd, 8))
    -                data = fp.saferead(size)
    +                data = fp.read(size)
                     fp.seek(here)
                 else:
                     data = ifd[8:8+size]
    
  2. Log in to comment