-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Cater to optional support of GD/GD2 image formats #15006
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
base: master
Are you sure you want to change the base?
Conversation
Prior to libgd 2.3.0, support for the proprietary GD and GD2 image formats has was mandatory. However, as of that version libgd can be built without support for these formats[1], and as of libgd 2.3.3 by default these formats are not supported[2]. If libgd is built without support for a certain image format, the respective reader and writer functions are still defined, but they are NOPs. However, PHP GD users expect the reader and writer function to only be defined, if there is actual support, so we're checking for the support during build time, and declare the `HAVE_GD_GD` macro only if support for the GD and GD2 image formats is available. We do not change the bundled libgd to make support for these formats optional, yet. [1] <libgd/libgd#428> [2] <https://github.com/libgd/libgd/blob/master/CHANGELOG.md#233---2021-09-12>
I updated the Ignore the first commit; to minimize the noise, it deletes all tests that fail with external libgd for unrelated reasons. Now,
It does look like the patch for bug 73869 made it into upstream libgd, so I'm not sure what the problem is there. Here's the log: $ cat ext/gd/tests/bug73869.log
---- EXPECTED OUTPUT
Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
bool(false)
Warning: imagecreatefromgd2(): "%s" is not a valid GD2 file in %s on line %d
bool(false)
---- ACTUAL OUTPUT
Warning: imagecreatefromgd2(): product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
in /home/mjo/src/php-src/ext/gd/tests/bug73869.php on line 2
Warning: imagecreatefromgd2(): "/home/mjo/src/php-src/ext/gd/tests/bug73869a.gd2" is not a valid GD2 file in /home/mjo/src/php-src/ext/gd/tests/bug73869.php on line 2
bool(false)
Warning: imagecreatefromgd2(): one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully
in /home/mjo/src/php-src/ext/gd/tests/bug73869.php on line 3
Warning: imagecreatefromgd2(): "/home/mjo/src/php-src/ext/gd/tests/bug73869b.gd2" is not a valid GD2 file in /home/mjo/src/php-src/ext/gd/tests/bug73869.php on line 3
bool(false)
---- FAILED |
I think that is due to our bundled libgd has Line 140 in 81da53f
but system libgd calls |
Ok, I pushed two more commits. The second one is trivial, to match both capital and lowercase 'p'. The first should handle the extra warning from the overflow by making the additional warning optional. I figure that will be easiest because then if/when you pull the commit into the bundled libgd, you can update the tests (make the warning NON-optional) at the same time and then easily merge them into the same branches. |
Support for `imagetypes()` implies to define the respective userland constant `IMG_GD`. We also fix the missing #ifdefs for the reader and writer function definitions.
Prior to libgd 2.3.0, support for the proprietary GD and GD2 image formats has was mandatory. However, as of that version libgd can be built without support for these formats[1], and as of libgd 2.3.3 by default these formats are not supported[2].
If libgd is built without support for a certain image format, the respective reader and writer functions are still defined, but they are NOPs. However, PHP GD users expect the reader and writer function to only be defined, if there is actual support, so we're checking for the support during build time, and declare the
HAVE_GD_GD
macro only if support for the GD and GD2 image formats is available.We do not change the bundled libgd to make support for these formats optional, yet.
[1] libgd/libgd#428
[2] https://github.com/libgd/libgd/blob/master/CHANGELOG.md#233---2021-09-12
Just the first step. Yet missing:
gd_info()
, PHP info and imagetypes()imagecreatefromstring()
and maybe more. I'll continue to work on this ASAP, but wouldn't be sad if someone else would take over, or at least help with testing on Linux with system libgd.