473 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
Daniel Scherzer 620cd6930f [%pS migration] Use %pS in ext/bcmath (#23147) 2026-10-04 17:59:37 -07:00
Ilia Alshanetsky 6bd5ab82aa Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  ext/bcmath: Clear the sign of BcMath\Number results that truncate to zero
2026-09-29 15:47:49 -04:00
Ilia Alshanetsky 6030e5637f Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/bcmath: Clear the sign of BcMath\Number results that truncate to zero
2026-09-29 15:47:47 -04:00
Ilia Alshanetsky 8184e9efec ext/bcmath: Clear the sign of BcMath\Number results that truncate to zero
A bc_num that is zero must carry PLUS, since bc_compare() orders by sign
first. The bc_divide() fast paths for a divisor of +/-1 or a power of ten,
bc_raise() with a positive exponent, and the Number add/sub/mul helpers
truncate to the requested scale and keep the operand sign, so
(new BcMath\Number('-0.001'))->div(1, 0) compares less than 0, is not
equal to 0, and makes sqrt() throw.

Closes GH-23967
2026-09-29 15:47:44 -04:00
Ilia Alshanetsky 1d004f0e71 Merge branch 'PHP-8.5'
* PHP-8.5:
  Clamp scale in bc_is_zero_for_scale to n_scale
2026-09-06 10:05:03 -04:00
Ilia Alshanetsky 18cd1501df Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Clamp scale in bc_is_zero_for_scale to n_scale
2026-09-06 10:04:57 -04:00
Ilia Alshanetsky 979c827cdc Clamp scale in bc_is_zero_for_scale to n_scale
Number::compare() may request a scale greater than the stored scale of a
zero result when the opposite operand has a larger scale. The helper then
walked past the shorter digit buffer.

Clamp the requested scale to the digits stored in the number.

Closes GH-23185
2026-09-06 10:03:46 -04:00
NickSdot 7ca205842e ext/bcmath: applied fixers to improve test robustness (#23129) 2026-08-22 14:08:15 +01:00
laokz 3855c7c143 tests/GHSA-x692-q9x7-8c3f.phpt: Add extensions required (#23408)
bccomp() is in bcmath extension. Add the requires to avoid test failure if bcmath extension not configured.

Signed-off-by: Kai Zhang <zhangkai@iscas.ac.cn>
2026-08-22 14:07:18 +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
Recep A. 4f83876af7 Fix out-of-bounds write in ext-bcmath bccomp() via bc_str2num()
When a fraction is truncated to a caller-supplied scale and then re-trimmed of
trailing zeros, str_scale was reduced but fractional_end was not, so
bc_copy_and_toggle_bcd() copied more bytes than were reserved by
bc_new_num_nonzeroed(). With small numbers allocated from the 256-byte stack
arena this is a stack-based OOB write reachable via bccomp($num1, $num2,
$scale), e.g. bccomp("1.901", "0", 2).

Keep fractional_end in sync with str_scale so the copy length matches the
reserved length.

Fixes GHSA-x692-q9x7-8c3f
2026-07-28 11:50:46 +02:00
ndossche a61c38a70b Merge branch 'PHP-8.5'
* PHP-8.5:
  [ci skip] Update heading
  soap: do not overwrite the parsed host on a protocol-relative redirect
2026-06-25 08:31:59 +02:00
ndossche cf9bb87ec2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  [ci skip] Update heading
  soap: do not overwrite the parsed host on a protocol-relative redirect
2026-06-25 08:31:03 +02:00
ndossche 1666d90b15 [ci skip] Update heading 2026-06-25 08:24:14 +02:00
Saki Takamachi 0d2d35312b Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/bcmath: bounds-check $precision in bcround() and Number::round() (#22182)
2026-06-07 12:19:57 +09:00
Saki Takamachi 16e217ee55 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/bcmath: bounds-check $precision in bcround() and Number::round() (#22182)
2026-06-07 12:18:40 +09:00
Volker Dusch c0fa54f796 ext/bcmath: bounds-check $precision in bcround() and Number::round() (#22182)
Fix ASAN issue withh entry points passed $precision to bc_round()
unchecked, allowing PHP_INT_MAX / PHP_INT_MIN to trigger oversized
allocations and signed overflow in libbcmath/src/round.c.

closes #22182
2026-06-07 12:15:20 +09:00
Tim Düsterhus ad7cce6527 zend_portability: Add ZEND_CONTAINER_OF() (#21903)
* zend_portability: Add `ZEND_CONTAINER_OF()`

* tree-wide: Use `ZEND_CONTAINER_OF()`

Changes made with Coccinelle:

    @@
    type T_container;
    identifier member;
    expression e;
    @@

    - (T_container *)(((char *)(e)) - offsetof(T_container, member))
    + ZEND_CONTAINER_OF(e, T_container, member)

    @@
    type T_container;
    identifier member;
    expression e;
    typedef uintptr_t;
    @@

    - (T_container *)(((uintptr_t)(e)) - offsetof(T_container, member))
    + ZEND_CONTAINER_OF(e, T_container, member)

    @@
    type T_container;
    identifier member;
    expression e;
    @@

    - (const T_container *)(((char *)(e)) - offsetof(T_container, member))
    + ZEND_CONTAINER_OF(e, T_container, member)

    @@
    type T_container;
    identifier member;
    expression e;
    typedef uintptr_t;
    @@

    - (const T_container *)(((uintptr_t)(e)) - offsetof(T_container, member))
    + ZEND_CONTAINER_OF(e, T_container, member)

* bcmath: Fix `get_bcmath_number_from_obj()` const-correctness

A follow-up change to the new `ZEND_CONTAINER_OF()` macro will preserve the
`const`-ness of the input pointer. By wrapping this macro inside a macro rather
an an inline function we can preserve the `const`-ness across all layers.

* zend_portability: Keep `const`-ness in `ZEND_CONTAINER_OF()`

* zend_portability: Add C++ version to `ZEND_CONTAINER_OF()`
2026-05-19 10:47:00 +02:00
Tim Düsterhus 7114314c5a tree-wide: Replace XtOffsetOf by its definition (#21899)
`offsetof()` is in `stddef.h` and thus always available. The extra macro is an
unnecessary layer of indirection.
2026-04-28 22:12:56 +02:00
Ben Ramsey e5c86d2428 license-update: ext/bcmath source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Tim Düsterhus 04f06e8cf2 zend_portability: Remove EMPTY_SWITCH_DEFAULT_CASE() (#20063)
There are several issues with this macro:

- It is incorrectly named: It's not an empty default case. It's an unreachable
  default case.
- It is hiding control flow in its definition, which can be confusing for
  humans and tools (such as Coccinelle) alike, because it looks like it would
  be a statement that belongs to the "current" case rather than opening a new
  one.

Since this macro is exactly as long as explicitly spelling out its definition
(excluding the useless `break;`), it is not even making the code any more
succinct.
2026-04-06 14:46:15 +02:00
Ilija Tovilo 21664fb935 Convert remaining K&R function declarations in libbcmath
These are already converted in 8.3. Backport minimal changes to 8.2, as the
latest version of Clang on macOS has stopped supporting the K&R syntax.

Closes GH-21636
2026-04-04 22:50:59 +02:00
Jorg Sowa 9caa0a7d50 Fix bc_str2num accepting strings with embedded null bytes
Closes GH-21492
2026-03-24 18:03:39 +01:00
Tim Düsterhus a15ba7672c zend_ini: Make ZEND_INI_GET_ADDR() return a void* pointer (#21119)
* zend_ini: Make `ZEND_INI_GET_ADDR()` return a `void*` pointer

Since the actual type of the storage location is not known, a `void*` is more
appropriate and avoids explicit casts that are no more safe than the implicit
cast from `void*`.

* tree-wide: Remove explicit casts of `ZEND_INI_GET_ADDR()`

* UPGRADING.INTERNALS
2026-02-04 11:11:11 +01:00
Arnaud Le Blanc d16e6f52a4 Generate C enums from internal enums, introduce Z_PARAM_ENUM() (#20917)
Update gen_stubs.php to generate C enums from internal enums, when the stub is annotated with @generate-c-enums. Enum values can be compared to the result of zend_enum_fetch_case_id(zend_object*).

The generated enums are added to separate files named {$extensionName}_decl.h, so that it's possible to include these from anywhere. _arginfo.h files would generate warnings if we tried to include them in a compilation unit that doesn't call the register_{$class} functions, for instance.

Introduce Z_PARAM_ENUM().

* Make ZEND_AST_CONST_ENUM_INIT a 4-children node

* Store enum case id in ZEND_AST_CONST_ENUM_INIT

* Store enum case id in instance

* Expose enum case_id internally

* Generate C enum for internal enums

* Introduce Z_PARAM_ENUM()

* Port extensions
2026-02-03 12:38:04 +01:00
Arnaud Le Blanc 65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Niels Dossche 57ce245e1e Reduce code bloat in arginfo by using specialised string releases (#20016)
* Reduce code bloat in arginfo by using specialised string releases

Comparing this patch to master (c7da728574),
with a plain configure command without any options:

```
   text	   data	    bss	    dec	    hex	filename
20683738	1592400	 137712	22413850	156021a	sapi/cli/php
20688522	1592400	 137712	22418634	15614ca	sapi/cli/php_old
```

We see a minor reduction of 0.023% in code size.

* Also use true for the other initialization line

* Also use specialized code for consts
2025-10-02 22:00:20 +02:00
Niels Dossche a380dcae4d Fix GH-20006: Power of 0 of BcMath number causes UB
Closes GH-20007.
2025-09-30 14:47:35 +02:00
Saki Takamachi edfd55c197 ext/bcmath: use vector in compare (#18859) 2025-06-21 01:34:42 +09:00
Saki Takamachi 2751064692 use XSSE for bcmath (#18770) 2025-06-06 08:25:52 +09:00
Niels Dossche 25e60d6ab1 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak when calloc() fails in php_readline_completion_cb()
  Fix GH-18641: Accessing a BcMath\Number property by ref crashes
2025-05-24 20:39:59 +02:00
Niels Dossche 64d511ef29 Fix GH-18641: Accessing a BcMath\Number property by ref crashes
The properties are virtual so we need a custom get_property_ptr_ptr
handler.

Closes GH-18637.
2025-05-24 20:38:33 +02:00
Saki Takamachi c5f3281446 ext/bcmath: Improving bcpow() performance (#18099) 2025-04-30 08:05:28 +09:00
Saki Takamachi c927d24af6 ext/bcmath: Use const qualifiers appropriately (#18284) 2025-04-11 12:39:31 +09:00
Saki Takamachi 1ce79eb219 ext/bcmath: In the arm processor environment, NEON is used to use SIMD. (#18130) 2025-03-26 07:48:02 +09:00
Saki Takamachi fb07c62f2c ext/bcmath: Extracted common logic into function and macro (#18103) 2025-03-19 18:10:12 +09:00
Saki Takamachi 6b6fde9098 ext/bcmath: If size of BC_VECTOR array is within 64 bytes, stack area is now used (#18065) 2025-03-15 08:43:43 +09:00
Saki Takamachi 843d2a9b5f ext/bcmath: bc_divide() small fix (#18060) 2025-03-15 08:41:14 +09:00
Saki Takamachi 32547f1127 ext/bcmath: If the result is 0, n_scale is set to 0. (#18056) 2025-03-14 17:52:50 +09:00
Saki Takamachi fa1effdb3c Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed pointer subtraction for scale (#17986)
2025-03-14 09:00:33 +09:00
Saki Takamachi 7c9872e255 Fixed pointer subtraction for scale (#17986)
Closes #17986
2025-03-14 09:00:00 +09:00
Saki TakamachiandNiels Dossche 4e4f1729dd ext/bcmath: Simplify bc_divide() code (#17987)
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-03-14 08:53:48 +09:00
Saki Takamachi 5bf6e2e378 Merge branch 'PHP-8.4'
* PHP-8.4:
  follow up for #17615
2025-01-29 19:25:05 +09:00
Saki Takamachi 18d96671a5 follow up for #17615
The deleted line has returned, so delete it again.
2025-01-29 19:25:03 +09:00
Saki Takamachi c9fa625e41 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed GH-17398: bcmul memory leak (#17615)
2025-01-29 19:15:23 +09:00