Repository navigation
Conversation
This was referenced Nov 7, 2026
Member
|
If I were you, I would split into 2 pr, the libgd part alone can take an undetermined time to move the needle. |
devnexen
reviewed
Nov 8, 2026
| --FILE-- | ||
| <?php | ||
| $path = __DIR__ . '/xbm_out_of_range.tmp.xbm'; | ||
| foreach ([['4294967298', '1'], ['1', '4294967298'], ['2147483648', '1'], ['-5', '1'], ['2147483647', '9']] as [$w, $h]) { |
Member
There was a problem hiding this comment.
note: the -5 x 1 and 2147483647 x 9 cases already return
false without the patch: -5 wraps to a zero byte count, and gdImageCreate()
rejects 2147483647 x 9 internally.
Member
Author
There was a problem hiding this comment.
Dropped them, along with 2147483648 x 1, which gdImageCreate() also rejects, and the row-byte guard, since gdImageCreate() already rejects any final size whose byte count would overflow. The test moves with the GD part.
Member
Author
|
Split: this PR now only covers getimagesize(). The bundled GD part will follow once libgd/libgd#1050 lands. |
devnexen
reviewed
Nov 9, 2026
XBM width and height were read with sscanf("%d"), whose behaviour on
overflow is undefined; glibc wraps 4294967298 to 2, so getimagesize()
reported a width of 2, and negative values were reported as negative
dimensions. Parse the value with strtol() and accept only 1 to INT_MAX.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An XBM file declaring
#define x_width 4294967298makes getimagesize() report a width of 2, because php_get_xbm() parses the dimension with sscanf("%d") and that overflow is undefined; negative values are reported as negative dimensions. This parses the value with strtol() and accepts only 1 to INT_MAX. The bundled GD reader has the same bug and will follow in a separate PR after libgd/libgd#1050.