The feeder knows this
{{{
except zlib.error as e:
# ignore zlib complaining on truncated stream, just feed
more
# data to parser (ticket #19457).
if e.args[0].startswith("Error -5"):
pass
else:
raise
}}}
but does not know this
{{{
from struct import error
...
except struct.error:
pass
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24544>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "b.png" added.
Valid but faulty image
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> Hi,
> second time I find a bug in the same function. Here, the function failed
> (exception raised and not caught) on a valid PNG file (this image:
> https://mega.co.nz/#!W0tXzBAK!iLprbqkVWFAzfcn2GUDRGHiH8Pxyi4DxCQi580shcec).
> The error raised by PIL is a `struct.error`, which should be expected but
> is not caught by the chunk feeder loop.
>
> The feeder knows this
>
> {{{
> except zlib.error as e:
> # ignore zlib complaining on truncated stream, just feed
> more
> # data to parser (ticket #19457).
> if e.args[0].startswith("Error -5"):
> pass
> else:
> raise
> }}}
>
> but does not know this
>
> {{{
> from struct import error
> ...
>
> except struct.error:
> pass
> }}}
New description:
Hi,
second time I find a bug in the same function. Here, the function failed
(exception raised and not caught) on a valid PNG file (this image:
https://mega.co.nz/#!W0tXzBAK!iLprbqkVWFAzfcn2GUDRGHiH8Pxyi4DxCQi580shcec).
The error raised by PIL is a `struct.error`, which should be expected but
is not caught by the chunk feeder loop.
The feeder knows this
{{{
except zlib.error as e:
# ignore zlib complaining on truncated stream, just feed
more
# data to parser (ticket #19457).
if e.args[0].startswith("Error -5"):
pass
else:
raise
}}}
but does not know this
{{{
from struct import error
...
except struct.error:
pass
}}}
when you catch the proper exception, the file header fed to the parser
becomes correct starting at offset 9214.
The good news is, it does not need tests.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/24544#comment:1>
Comment (by artscoop):
Pull request made here: https://github.com/django/django/pull/4398
--
Ticket URL: <https://code.djangoproject.com/ticket/24544#comment:2>
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/24544#comment:3>
* has_patch: 0 => 1
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/24544#comment:4>
* needs_better_patch: 0 => 1
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/24544#comment:5>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"2fc19b92387d4248c715edfbf38658238978abb6" 2fc19b92]:
{{{
#!CommitTicketReference repository=""
revision="2fc19b92387d4248c715edfbf38658238978abb6"
Fixed #24544 -- Fixed get_image_dimensions() on image buffers that Pillow
fails to parse.
Thanks Steve Kossouho for the report and original patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24544#comment:6>