2596 Commits
Author SHA1 Message Date
Ilija Tovilo d6373dfe15 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:33:23 +02:00
Ilija Tovilo c7273b9ba8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:30:04 +02:00
Ilija Tovilo 8a94bb3822 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:27:03 +02:00
Ilija Tovilo c1a5f468d0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:12:35 +02:00
3584a98bda Avoid state corruption via bailout
- Replace bailout on OOM with UnwindExit
- Properly reset various globals that may be accessed during startup

Fix GHSA-w8hw-w9fx-j79w (CVE-2026-109618)
Fix GHSA-6wmf-4rv5-p3rp (CVE-2026-109619)

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Jakub Zelenka <bukka@php.net>
Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2026-10-21 16:06:22 +02:00
Shivam MathurandDemon 703ca47f12 ext/gd: Drop useless and doubtful MSVC specific code (libgd/libgd@f1480ab) (#24316)
(cherry picked from commit 974526b244)

Co-authored-by: Demon <hyh19962008@gmail.com>
2026-10-14 17:20:36 +05:30
Daniel Scherzer d746ea6200 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  NEWS
  ext/gd: fix undefined behavior with GIFs with problematic LZW compression data
2026-09-29 17:59:49 -07:00
Daniel Scherzer f8be041aaa Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  NEWS
  ext/gd: fix undefined behavior with GIFs with problematic LZW compression data
2026-09-29 17:58:25 -07:00
Daniel Scherzer 2cea4a358d ext/gd: fix undefined behavior with GIFs with problematic LZW compression data
Apply the changes from libgd/libgd@9fa3abd2e6 in
order to fix undefined behavior from out-of-bounds reads when creating a GIF
with problematic LZW compression data.
2026-09-29 17:53:29 -07:00
Daniel Scherzer a423c90e45 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  NEWS
  ext/gd: fix undefined behavior with GD2 images with `INT_MAX`-sized chunks
2026-09-28 16:25:51 -07:00
Daniel Scherzer 90064889ef Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  NEWS
  ext/gd: fix undefined behavior with GD2 images with `INT_MAX`-sized chunks
2026-09-28 16:24:45 -07:00
Daniel Scherzer b8c63871c8 ext/gd: fix undefined behavior with GD2 images with INT_MAX-sized chunks
Apply the changes from libgd/libgd@7ff626c48a in
order to fix undefined behavior when creating a GD2 image when a compressed
chunk claims to take `INT_MAX` space.
2026-09-28 15:50:07 -07:00
Dmytro Kulyk 67135cb97b gen_stub: Conditionally include zend_attributes.h to arginfo based on usage (#21570)
Headers required by the generated code (zend_attributes.h, zend_constants.h, zend_enum.h) are collected during generation and emitted as includes at the top of the arginfo file, with the same preprocessor conditions and PHP version guards as the code that needs them.

Removes the manual zend_attributes.h and zend_enum.h includes from sources that only needed them for the arginfo file they include.
2026-09-06 21:25:20 +02:00
lacatoireandNickSdot dddbca6ec6 ext/gd: report $size with the argument number of the function called
php_imagettftext_common() serves the bbox functions, where $size is
argument #1, and the drawing ones, where it is #2, but its two size
checks hardcode 2. imageftbbox(NAN, ...) therefore blamed $angle.

Also fix the upper bound itself: (double)LONG_MAX rounds up to 2^63, so
(double)LONG_MAX / 64 is 2^57 and the check let 2^57 through, whose
product with 64 is LONG_MAX + 1. The bound is now exclusive, and the
reported values use integer division, which gives the largest size that
is actually representable. The lower bound stays inclusive:
(double)LONG_MIN / 64 is exactly -2^57 and its product with 64 is
LONG_MIN.

Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com>

Close GH-23541
2026-09-04 04:47:38 +01:00
Weilin Du ec93b0b941 Fix GH-23459: Improve imagegrabscreen() performance on Windows (#23485)
A roughly 814x optimization in total for the two function.
2026-08-29 00:25:55 +08:00
David Carlier a2a2029d43 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-23457: imagebmp() is extremely slow when writing to a file
2026-08-26 12:38:24 +01:00
David Carlier 5c0e8c7b8a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-23457: imagebmp() is extremely slow when writing to a file
2026-08-26 12:38:18 +01:00
Lazizbek Ergashev d7778413a2 Fix GH-23457: imagebmp() is extremely slow when writing to a file
imagebmp() writes its pixel data a byte at a time, and the gd stream
context turned each of those bytes into its own php_stream_write() call.
PHP streams do no write buffering, so a 1920x1080 truecolor image cost
about six million write syscalls. libgd's own FILE context does not show
this because stdio buffers for it.

Buffering the stream context in 8 KB chunks takes that image from 9.5s
to 0.02s here, with byte-identical output. imagewbmp(), imagegd() and
imagegd2() go through the same context and were writing per byte too, so
they get the same fix. imagexbm() goes through the same context but
writes its output via putBuf rather than per-byte putC, so it was not
affected by this bug and sees no change from this patch.

Close GH-23460
2026-08-26 12:33:47 +01:00
Weilin Du dcce3459c6 ext/gd: Add ZPP specifier for array|float parameters (#23384)
Follow-up #23356.
Fixed imageaffinematrixget() to enforce the documented array|float type
for the $options parameter.
2026-08-21 00:05:00 +08:00
Weilin Du 670165ef83 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/gd: Fix incorrect argument numbers in GD affine function errors (#23356)
2026-08-19 13:45:03 +08:00
Weilin Du 75e28802b4 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/gd: Fix incorrect argument numbers in GD affine function errors (#23356)
2026-08-19 13:43:56 +08:00
Weilin Du aad2b534de ext/gd: Fix incorrect argument numbers in GD affine function errors (#23356)
This fixes wrong argument in error message in imageaffinematrixget and
mageaffinematrixconcat.
2026-08-19 13:40:28 +08:00
David CARLIER 60a5e8814a Fix GH-23272: ext/gd fails to build without the iconv extension (#23273)
gdkanji.c includes <iconv.h> only when HAVE_ICONV_H or HAVE_ICONV is
set, but HAVE_ICONV_T_DEF was defined whenever <iconv.h> declares the
type, dropping its fallback typedef. Detect iconv in gd's own config
and define both macros together.
2026-08-14 12:26:42 +01:00
NickSdot 4ba23348c8 ext/gd: applied fixers to improve test robustness (#23132) 2026-08-14 17:21:47 +08:00
NickSdot 1d2ea5ce22 Run tests in parallel by default (#22939)
Runs the test suite in parallel by default; automatically selects up to 10 workers. Explicit -j1 remains the opt-out to run tests serial. Smaller batches improve balancing.
2026-08-10 11:33:43 +02:00
Lothar Serra Mari 6ce322e0d1 ext/gd: Fix two external libgd tests (#23138) 2026-08-09 15:01:41 +01:00
Ilija Tovilo fb21752483 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix out-of-bounds write in ext-bcmath bccomp() via bc_str2num()
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:58:05 +02:00
Ilija Tovilo e5c3b4b083 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix out-of-bounds write in ext-bcmath bccomp() via bc_str2num()
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:51:44 +02:00
Ilija Tovilo d3f361c3b7 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:50:34 +02:00
Ilija Tovilo 416985389d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add NEWS entries
  Fix GHSA-vc5h-9ppw-p5f3: phar circular symlink crash
  Fix SQL injection in ext-pgsql via E'...' backslash breakout
  libgd patch for CVE-2026-9672
2026-07-28 11:41:07 +02:00
Ilija Tovilo fcd691b377 libgd patch for CVE-2026-9672
Patch by Pierre Joye (pierrejoye).
2026-07-28 02:48:11 +02:00
Calvin Buckley 0a12b3e826 Remove param argument from php_verror (#22865)
* Remove param argument from php_verror

Now that docref has been knocked out and error_include_args exists,
remove this argument. Callers will be updated accordingly.

* Remove param from exif

* Remove param from snmp (no changes for tests needed)

* Remove param from gd (no changes for tests needed)

* Remove param from openssl

* Document param change to php_verror
2026-07-24 01:56:34 -03:00
Shivam Mathur c329a71037 ext/gd: remove libde265 and x265 checks on Windows (#22869) 2026-07-23 19:32:07 +05:30
David CARLIER ea8f2cff16 ext/gd: conflicting iconv_t typedef breaking the Solaris build. (#22810)
The gd 2.4 sync guarded gdkanji.c's 'typedef void *iconv_t' fallback
with HAVE_ICONV_T_DEF, which the bundled build never defined. On
Solaris <iconv.h> declares iconv_t as a struct pointer, so it clashed.
Define HAVE_ICONV_T_DEF when <iconv.h> already provides iconv_t.
2026-07-23 12:45:38 +01:00
Gina Peter Banyard 34c686a5b4 stream: remove path parameter in stream error functions (#22792)
Instead rely on the mechanism gated by the error_include_args INI to display them.

This actually aligns the behaviour of what was accepted in https://wiki.php.net/rfc/display_error_function_args.
2026-07-19 16:15:01 +01:00
Pierre Joye d826d49483 Sync gd 2 4 (#22532)
1st part of syncing bundled LibGd to ext/gd/libgd
# Updated/Fixed

- Color Match improvement using Lab* + Delta-E and actual % as input
- Fix and improve freetype rendering and merge both php's libgd + libgd "new encoding"
 -  Fix RAMQ rendering
- All codecs with conformance tests (upstream, C)
- Perceptual difference (upstream C, will be exposed so php's tests can rely on it
- libgd codecs include gif, bmp, webp and jxl full support including animation. Tiff read/write multipages. all BMP format supported but OS/2.

Many of these additions or changes work already with existing php's apis.

2D vector APIs and all new Codecs or Gd\* APIs will be a separe PR+RFC. See https://wiki.php.net/rfc/ext-gd-2.4
2026-07-16 21:46:18 +07:00
David Carlier f0c603ba0d Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/gd/tests/gh19{666,739}.phpt: skip for external libgd
2026-07-13 05:11:28 +01:00
David Carlier 35452fb43b Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/gd/tests/gh19{666,739}.phpt: skip for external libgd
2026-07-13 05:11:20 +01:00
Michael Orlitzky b51f575ba1 ext/gd/tests/gh19{666,739}.phpt: skip for external libgd
These two are regression tests for the bundled libgd, we have to skip
them if an external libgd is used.

close GH-22711
2026-07-13 05:11:05 +01:00
Ilia Alshanetsky 348c13954f Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/gd: pack imageloadfont short-read test in native byte order
2026-06-24 09:51:37 -04:00
Ilia Alshanetsky 6d9975e452 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/gd: pack imageloadfont short-read test in native byte order
2026-06-24 09:49:47 -04:00
Ilia Alshanetsky 5af56148a2 ext/gd: pack imageloadfont short-read test in native byte order
imageloadfont_short_read packed the font header with pack('V4', ...)
(little-endian), but imageloadfont() reads the header as native-endian
ints. On big-endian hosts (PPC64 nightly) the byte-swapped values
overflow the INT_MAX guard before the FLIPWORD fallback runs, so the
font is rejected and the test fails. Pack the fields with 'i' to keep
the header valid regardless of host endianness.

Closes GH-22416
2026-06-24 09:47:19 -04:00
Ilia Alshanetsky 0ab77bc784 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/gd: fix out-of-bounds write reading font header on short reads
2026-06-21 12:35:00 -04:00
Ilia Alshanetsky 92489a2498 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/gd: fix out-of-bounds write reading font header on short reads
2026-06-21 12:32:38 -04:00
Ilia Alshanetsky df1250dc64 ext/gd: fix out-of-bounds write reading font header on short reads
imageloadfont() read the font header with `(char*)&font[b]`, which scales
the byte counter b by sizeof(gdFont) rather than advancing one byte, so a
short php_stream_read() (deliverable by a user stream wrapper) makes the
loop write hdr_size-b bytes past the emalloc(sizeof(gdFont)) buffer. Index
the destination by bytes, matching the body read a few lines below.

Closes GH-22380
2026-06-21 12:29:31 -04:00
Tim Düsterhus 69e023fd84 ext/*: Make X_from_obj(zend_object *obj) functions macros (#22183)
* ext/*: Make `X_from_obj(zend_object *obj)` functions macros

With the introduction of the `ZEND_CONTAINER_OF()` macro we can now preserve
whether or not the `zend_object *` is `const` when extracting the
class-specific struct. This change will allow to use `const zend_object *` in
more locations.

Changes performed with Coccinelle followed by some manual cleanup for comment
and whitespace formatting:

    @a@
    attribute name zend_always_inline;
    type T;
    identifier obj;
    identifier f;
    typedef zend_object;
    @@

     T* f(zend_object *obj) { return ZEND_CONTAINER_OF(obj, T, std); }
    + #define f(obj) ZEND_CONTAINER_OF(obj, T, std)

    @@
    identifier a.f;
    @@

    - f(...) { ... }

    @b@
    attribute name zend_always_inline;
    type T;
    identifier obj;
    identifier f;
    typedef zend_object;
    @@

     T* f(zend_object *obj) { return ZEND_CONTAINER_OF(obj, T, zo); }
    + #define f(obj) ZEND_CONTAINER_OF(obj, T, zo)

    @@
    identifier b.f;
    @@

    - f(...) { ... }

* sockets: Fix build

* odbc: Fix build
2026-06-01 10:21:03 +02:00
David Carlier 64ebf2ffe8 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-19730: undefined behavior in gd_interpolation.c.
2026-05-30 13:22:10 +01:00
David Carlier 6007c09081 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-19730: undefined behavior in gd_interpolation.c.
2026-05-30 13:22:02 +01:00
David Carlier cb8f7bd434 Fix GH-19730: undefined behavior in gd_interpolation.c.
Port libgd f6202ec0de1c8340cf9b69c4a86c84fc63703207: validate the
computed bounding box in gdTransformAffineBoundingBox before casting
the floating-point coordinates to int, and propagate the failure
through gdTransformAffineGetImage.

close GH-22149
2026-05-30 13:21:39 +01:00
David Carlier 68d01d2afa Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-19739: imageellipse/imagefilledellipse overflow.
2026-05-24 21:34:36 +01:00