-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixed comparison warnings #4752
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -742,8 +742,8 @@ j2k_decode_entry(Imaging im, ImagingCodecState state) | |||||||||
swapped), bail. */ | ||||||||||
if (tile_info.x0 >= tile_info.x1 | ||||||||||
|| tile_info.y0 >= tile_info.y1 | ||||||||||
|| tile_info.x0 < image->x0 | ||||||||||
|| tile_info.y0 < image->y0 | ||||||||||
|| tile_info.x0 < (OPJ_INT32)image->x0 | ||||||||||
|| tile_info.y0 < (OPJ_INT32)image->y0 | ||||||||||
|| tile_info.x1 - image->x0 > im->xsize | ||||||||||
|| tile_info.y1 - image->y0 > im->ysize) { | ||||||||||
Comment on lines
747
to
748
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The previous 4 lines verify that |
||||||||||
state->errcode = IMAGING_CODEC_BROKEN; | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ alloc_array(Py_ssize_t count) | |
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
if (count > (SIZE_MAX / (2 * sizeof(double))) - 1 ) { | ||
if ((unsigned long long)count > (SIZE_MAX / (2 * sizeof(double))) - 1 ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Immediately before this, if |
||
PyErr_NoMemory(); | ||
return NULL; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x0
andy0
are signed, as set by OpenJPEG. So the tile offset can be theoretically negative.Part of this block is to check 'if the tile is outside the image area'. If the tile offset is negative, that is definitely outside the image area.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this cause issues for images with
x0
ory0
greater than 2**31, since image->x0 is unsigned? The following suggestion would catch both cases:One could argue that such an image could have no valid tiles, but I do not see another check specifically for that case.