204 Commits
Author SHA1 Message Date
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
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
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
Jorg Sowa 9caa0a7d50 Fix bc_str2num accepting strings with embedded null bytes
Closes GH-21492
2026-03-24 18:03:39 +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
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
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
Saki Takamachi 4c90bb2da4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fixed GH-17398: bcmul memory leak (#17615)
2025-01-29 19:15:10 +09:00
Saki Takamachi 5a4832f97b Fixed GH-17398: bcmul memory leak (#17615)
Changed BCG memory allocation to be forcibly released in
PHP_GSHUTDOWN_FUNCTION regardless of refcount.

Fixes #17398
Closes #17615
2025-01-29 19:12:18 +09:00
Saki Takamachi 2b36680f0a Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed GH-17275: Fixed the calculation logic of dividend scale (#17279)
2024-12-27 21:36:36 +09:00
Saki Takamachi ef036090d9 Fixed GH-17275: Fixed the calculation logic of dividend scale (#17279)
Fixes #17275
Closes #17279
2024-12-27 21:36:26 +09:00
Saki Takamachi 0507b83360 Merge branch 'PHP-8.4'
* PHP-8.4:
  Correctly round rounding mode with zero edge case (#17065)
2024-12-17 00:17:38 +09:00
Saki Takamachi 52ebdfbe00 Correctly round rounding mode with zero edge case (#17065)
Fixes #17064
Closes #17065
2024-12-17 00:17:23 +09:00
Saki Takamachi bb13556240 Merge branch 'PHP-8.4'
* PHP-8.4:
  Correctly compare 0 and -0 (#17051)
2024-12-07 01:52:44 +09:00
Saki Takamachi 063c3c8522 Correctly compare 0 and -0 (#17051)
Fixes #17049
Closes #17051
2024-12-07 01:52:30 +09:00
Saki Takamachi 5930278702 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed GH-16978: Avoid unnecessary padding with leading zeros (#16988)
2024-11-29 21:28:48 +09:00
Saki Takamachi d17ed3445d Fixed GH-16978: Avoid unnecessary padding with leading zeros (#16988)
Fixed an issue where leading zeros were padded beyond the allocated memory.

fixes #16978
closes #16988
2024-11-29 21:28:38 +09:00
Saki Takamachi 9b3af0253f Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed a bug in BcMath\Number::pow() and bcpow() when raising negative powers of 0. (#16694)
2024-11-20 00:17:38 +09:00
Saki Takamachi 2c8662d6f9 Fixed a bug in BcMath\Number::pow() and bcpow() when raising negative powers of 0. (#16694)
Closes #16694
Fixes #16236
2024-11-20 00:16:52 +09:00
Saki Takamachi f464298c8e Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed a bug where size_t underflows (#16696)
  Added early return case when result is 0 (#16697)
2024-11-05 08:43:58 +09:00
Saki Takamachi fd1dff988e Fixed a bug where size_t underflows (#16696)
fixes #16262
closes #16696
2024-11-05 08:41:09 +09:00
Saki Takamachi 2fe7719a44 Added early return case when result is 0 (#16697)
fixes #16265
closes #16697
2024-11-05 08:38:38 +09:00