Commit graph

825 commits

Author SHA1 Message Date
David Carlier
ed18fd073a
Merge branch 'PHP-8.3' into PHP-8.4 2025-02-14 15:28:48 +00:00
David Carlier
4d7d01d18e
Fix GH-17772: imagepalettetotruecolor segfault on invalid truecolor pixel.
close GH-17777
2025-02-14 15:28:33 +00:00
Christoph M. Becker
38365a44d0
Add support for reading GIFs without colormap
Cf. <fc38677e80>.

Closes GH-17364.
2025-01-09 12:06:24 +01:00
Christoph M. Becker
12e4ee492b
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix libgd 223: gdImageRotateGeneric() does not properly interpolate
2025-01-06 20:38:34 +01:00
Christoph M. Becker
47683487f8
Fix libgd 223: gdImageRotateGeneric() does not properly interpolate
We port the respective upstream fix[1].  We only run the test against
bundled libgd, since external libgd may yield different results.

Cf. <2b26be874d>.

Closes GH-17380.
2025-01-06 20:37:23 +01:00
Christoph M. Becker
61dcfc4c9a
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17373: imagefttext() ignores clipping rect for palette images
2025-01-06 14:59:03 +01:00
Christoph M. Becker
ec90367cd8
Fix GH-17373: imagefttext() ignores clipping rect for palette images
We apply the same fix that has been applied to external libgd at least
as of 2.0.29.

To avoid issues regarding minor FreeType rendering differences, the
test case does not compare against an image, but rather checks that all
pixels outside the clipping rect have the background color.

Closes GH-17374.
2025-01-06 14:57:46 +01:00
Christoph M. Becker
5a01c3293a
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17349: Tiled truecolor filling looses single color transparency
2025-01-04 14:54:11 +01:00
Christoph M. Becker
2c658f422d
Fix GH-17349: Tiled truecolor filling looses single color transparency
This is porting the relevant part of a previous upstream commit[1] to
align the behavior of our bundled libgd with upstream.  It should be
noted that this only works if the image actually has a transparent
color.

[1] <4770e2b2d5>

Closes GH-17351.
2025-01-04 14:53:18 +01:00
Christoph M. Becker
12ecdad183
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Port fix for libgd bug 276
2024-12-25 16:29:06 +01:00
Christoph M. Becker
643a77dda3
Port fix for libgd bug 276
The issue that BMP RLE occasionally swallowed some pixels[1] had been
fixed long ago in libgd, but apparently it has been overlooked to port
it to our bundled libgd.

We also introduce the test helper `test_image_equals_image()` which
compares in-memory images for equality.

[1] <https://github.com/libgd/libgd/issues/276>

Closes GH-17250.
2024-12-25 16:27:20 +01:00
Niels Dossche
d7e7e2b338
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16559: UBSan abort in ext/gd/libgd/gd_interpolation.c:1007
2024-10-23 20:10:04 +02:00
Niels Dossche
6d6afd9a83
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16559: UBSan abort in ext/gd/libgd/gd_interpolation.c:1007
2024-10-23 20:09:39 +02:00
Niels Dossche
e1e1e64a32
Fix GH-16559: UBSan abort in ext/gd/libgd/gd_interpolation.c:1007
The `uchar_clamp` function was backported from old code, this backports
it from new code.

Closes GH-16562.
2024-10-23 20:09:12 +02:00
Christoph M. Becker
055b15f08c
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16427: Unchecked libavif return values
2024-10-14 13:54:52 +02:00
Christoph M. Becker
05176adc4e
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16427: Unchecked libavif return values
2024-10-14 13:53:42 +02:00
Christoph M. Becker
b817a4f718
Fix GH-16427: Unchecked libavif return values
Prior to libavif 1.1.0, `avifAlloc()` was infallible (it called
`abort()` on OOM conditions); thus, several API functions which used
`avifAlloc()` did not report failure.  That changed as of libavif
1.0.0[1], so checking and handling failure conditions can now be done.
However, due to `avifAlloc()` being fallible as of libavif 1.1.0, this
error checking and handling is mandatory to avoid more serious issues.

[1] <eb02b2ec52/CHANGELOG.md (L273-L281)>

Closes GH-16434.
2024-10-14 13:52:45 +02:00
David Carlier
7f1fd0646b
Merge branch 'PHP-8.3' into PHP-8.4 2024-10-07 13:05:41 +01:00
David Carlier
7c43f68c98
Merge branch 'PHP-8.2' into PHP-8.3 2024-10-07 13:05:32 +01:00
David Carlier
a2bdfeff4f
Fix GH-16257 imagescale underflow on RGB channels.
backport of 948bb0a5c2

close GH-16257
2024-10-07 13:05:05 +01:00
David Carlier
215c61f9c7
Merge branch 'PHP-8.3' into PHP-8.4 2024-10-05 11:34:59 +01:00
David Carlier
8ff179529a
Merge branch 'PHP-8.2' into PHP-8.3 2024-10-05 11:34:49 +01:00
David Carlier
54973c9366
Fix GH-16232: bitshift overflow on wbmp file content reading.
backport from a8f1d5cab0

close GH-16239
2024-10-05 11:34:31 +01:00
Christoph M. Becker
f89eb15f72
Port libgd/libgd/pull/711 (GH-16016)
Note that this is not actually security related[1], but still a
reasonable sanity check.

"If a function be advertised to return an error code in the event of
difficulties, thou shalt check for that code, yea, even though the
checks triple the size of thy code and produce aches in thy typing
fingers, for if thou thinkest it cannot happen to me, the gods shall
surely punish thee for thy arrogance." – Henry Spencer

[1] <https://github.com/libgd/libgd/issues/697#issuecomment-2369613187>
2024-09-24 13:58:31 +02:00
David Carlier
307565d577
ext/gd: porting gdImageClone to the bundled libgd version.
close GH-15640
2024-08-29 23:13:20 +01:00
Christoph M. Becker
9b41c8b1b5
Declare gdImageGetInterpolationMethod() for bundled GD (GH-15329)
When this function has been added to our bundled GD[1], it had been
overlooked to also declare it in gd.h, like it's done in libgd.  While
MSVC doesn't have any issues with this, clang reports an error.

[1] <03bd4333f6>
2024-08-10 16:57:48 +02:00
Christoph M. Becker
6727f548b0
Port "gd2: use existing overflow2() rather than ad-hoc version" (#15090)
We port this modification[1] from libgd into our bundled libgd, because
the change makes sense, and we want the code bases to stay in sync as
close as possible.

We also apply a quick fix to the respective test.

[1] <f0a059be6c>
2024-07-24 14:18:36 +02:00
David Carlier
79c134a6e8
Merge branch 'PHP-8.3' 2024-07-13 17:00:53 +01:00
David Carlier
10a94f846d
Merge branch 'PHP-8.2' into PHP-8.3 2024-07-13 16:59:30 +01:00
Denis Ryabov
b456ae8d34
Restore Warning instead of Fatal Error in gd_webp.c
According to the docs (https://www.php.net/manual/en/function.imagecreatefromwebp.php and https://www.php.net/manual/en/function.imagewebp.php), `false` should be returned on errors (similar to other functions of the `gd` extension), but actually all errors result in a `Fatal Error`. It doesn't look normal when trying to read an empty file or a file in the wrong format causes the program to stop. The problem seems to be related to a mega-patch that replaced `zend_error` with `zend_error_noreturn` almost everywhere. My patch fixes this behavior by switching from `zend_error_noerror` to `gd_error` (i.e. to `E_WARNING` level). All necessary memory cleanup is already in the code (as it was before the "zend_error_noreturn" patch).

Close GH-13774
2024-07-13 16:58:54 +01:00
Peter Kokot
c44834d8ad
Trim trailing whitespace (#14721) 2024-06-29 18:41:45 +02:00
Niels Dossche
934e385640 gd: change uses of sprintf into snprintf 2024-06-14 08:12:03 -07:00
Peter Kokot
a82d86479c
Replace WIN32 conditions with _WIN32 or PHP_WIN32 (#14462)
* Replace WIN32 conditions with _WIN32 or PHP_WIN32

WIN32 is defined by the SDK and not defined all the time on Windows by
compilers or the environment. _WIN32 is defined as 1 when the
compilation target is 32-bit ARM, 64-bit ARM, x86, or x64. Otherwise,
undefined.

This syncs these usages one step further.

Upstream libgd has replaced WIN32 with _WIN32 via
c60d9fe577

PHP_WIN32 is added to ext/sockets/sockets.stub.php as done in other
*.stub.php files at this point.

* Use PHP_WIN32 in ext/random

* Use PHP_WIN32 in ext/sockets

* Use _WIN32 in xxhash.h as done upstream

See https://github.com/Cyan4973/xxHash/pull/931

* Update end comment with PHP_WIN32
2024-06-10 21:59:41 +02:00
Gina Peter Banyard
07a48517ac
Merge branch 'PHP-8.3'
* PHP-8.3:
  ext/readline: Fix [-Wcalloc-transposed-args] compiler warning
  ext/pdo_mysql: Fix [-Wcalloc-transposed-args] compiler warning
  ext/gd: Fix [-Wcalloc-transposed-args] compiler warning
  ext/ffi: Fix [-Wenum-int-mismatch] compiler warning
  ext/bcmath: Fix [-Wenum-int-mismatch] compiler warning
2024-05-21 12:23:45 +01:00
Gina Peter Banyard
b2c0db1f89
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/readline: Fix [-Wcalloc-transposed-args] compiler warning
  ext/pdo_mysql: Fix [-Wcalloc-transposed-args] compiler warning
  ext/gd: Fix [-Wcalloc-transposed-args] compiler warning
  ext/ffi: Fix [-Wenum-int-mismatch] compiler warning
  ext/bcmath: Fix [-Wenum-int-mismatch] compiler warning
2024-05-21 12:21:46 +01:00
Gina Peter Banyard
3c45152798
ext/gd: Fix [-Wcalloc-transposed-args] compiler warning 2024-05-21 12:17:25 +01:00
Peter Kokot
ba8633a9ce
Use fabsf() and floorf() unconditionally in bundled libgd (#13624)
These are available since C99 with math.h also on Windows, without
requiring checking. Upstream libgd uses floorf() unconditionally and
doesn't use fabsf().
2024-03-08 19:28:52 +01:00
Peter Kokot
b41a5023f9
Remove malloc.h (#13436)
This removes the deprecated malloc.h header Autoconf check on *nix
systems and its HAVE_MALLOC_H symbol. It can be replaced mostly with the
stdlib.h. The libgd usptream also doesn't include it anymore.

On Windows, it is still used for some memory allocation functions, but
can be replaced with stdlib.h in the future.
2024-02-20 18:02:54 +01:00
Niels Dossche
b06fedb41d Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-10614: imagerotate will turn the picture all black, when rotated 90
2024-01-26 18:16:29 +01:00
Niels Dossche
b76ef301a0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-10614: imagerotate will turn the picture all black, when rotated 90
2024-01-26 18:16:21 +01:00
Niels Dossche
f26dd1354b Fix GH-10614: imagerotate will turn the picture all black, when rotated 90
This is a backport of the upstream libgd PR that was recently committed
[1].

[1] https://github.com/libgd/libgd/pull/862

Closes GH-13246.
2024-01-26 18:15:52 +01:00
Niels Dossche
b8ff8c04f8 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-10344: imagettfbbox(): Could not find/open font UNC path
  Fix GH-13037: PharData incorrectly extracts zip file
2024-01-25 20:07:52 +01:00
Niels Dossche
78986a6734 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-10344: imagettfbbox(): Could not find/open font UNC path
  Fix GH-13037: PharData incorrectly extracts zip file
2024-01-25 20:07:33 +01:00
Niels Dossche
4a48729438 Fix GH-10344: imagettfbbox(): Could not find/open font UNC path
libgd uses an incorrect absolute path check in gdft.c.
It checks if either the path starts with a '/' (only valid on Posix
btw), or whether it contains something of the form C:\ or C:/.
However, this overlooks the possibility of using UNC paths on Windows.
As we already do PHP-specific stuff with VCWD_ macros, use
IS_ABSOLUTE_PATH to check for an absolute path which will take into
account UNC paths as well.

Closes GH-13241.
2024-01-25 20:06:28 +01:00
Ilija Tovilo
692cea5cbc
Use zend_error_noreturn for E_ERROR consistently
To be clear, these already don't return. zend_error_noreturn just hints at this
fact through the ZEND_NORETURN attribute.

Closes GH-12204
2023-09-14 11:44:55 +02:00
Javier Eguiluz
732d92c0e5
[skip ci] Fix various typos and grammar issues (#11143) 2023-04-28 11:05:32 +02:00
Christoph M. Becker
b78c087b32
Fix typo (Paletter → Palette)
This also aligns the error message with upstream[1].

[1] <https://github.com/libgd/libgd/blob/gd-2.3.3/src/gd_webp.c#L182>

Closes GH-9414.
2022-08-24 13:40:16 +02:00
Christoph M. Becker
98a4ab2266
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix imagecreatefromavif() memory leak
2022-06-17 17:31:48 +02:00
Christoph M. Becker
036bed01ce
Fix imagecreatefromavif() memory leak
This has been reported as https://github.com/libgd/libgd/issues/831.
We port the respective fix to our bundled libgd.

Closes GH-8812.
2022-06-17 17:30:57 +02:00
Christoph M. Becker
0052af2a67
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed libpng warning when loading interlaced images
2022-02-08 10:48:58 +01:00