python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.32k stars 2.23k forks source link

Add check for positive xsize/ysize in ImagingFliDecode #8406

Closed Yay295 closed 1 month ago

Yay295 commented 2 months ago

Fixes #8405

I put the check near the top, but is there any valid reason xsize or ysize would be 0, and the check would need to be later in the code?

radarhere commented 2 months ago

is there any valid reason xsize or ysize would be 0

No. Images that say one of their dimensions are zero will be stopped at https://github.com/python-pillow/Pillow/blob/731bcda904544d9d26bce268eca3a5cb4fcc1c46/src/PIL/ImageFile.py#L154-L156

Even if you consider just the C decoding process, we have https://github.com/python-pillow/Pillow/blob/731bcda904544d9d26bce268eca3a5cb4fcc1c46/src/decode.c#L189-L192

radarhere commented 1 month ago

My minor concern with this strategy is that we could make someone reading the code think that xsize might be zero, which as I've said, shouldn't happen.

I've created #8408 as an alternative to this.

radarhere commented 1 month ago

8408 has been merged instead.