Add check for positive xsize/ysize in ImagingFliDecode by Yay295 · Pull Request #8406 · python-pillow/Pillow
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?
is there any valid reason
xsizeorysizewould be 0
No. Images that say one of their dimensions are zero will be stopped at
| if not self.mode or self.size[0] <= 0 or self.size[1] <= 0: | |
| msg = "not identified by this driver" | |
| raise SyntaxError(msg) |
Even if you consider just the C decoding process, we have
| if (state->xsize <= 0 || state->xsize + state->xoff > (int)im->xsize || | |
| state->ysize <= 0 || state->ysize + state->yoff > (int)im->ysize) { | |
| PyErr_SetString(PyExc_ValueError, "tile cannot extend outside image"); | |
| return NULL; |
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.
#8408 has been merged instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters