593 Commits
Author SHA1 Message Date
ndossche 1d901925f0 Merge branch 'PHP-8.6'
* PHP-8.6:
  [ci skip] Skip test for MSAN
2026-10-27 20:36:52 +01:00
ndossche 76c8a4d13e Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  [ci skip] Skip test for MSAN
2026-10-27 20:36:46 +01:00
ndossche 6c1559d0e5 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  [ci skip] Skip test for MSAN
2026-10-27 20:36:40 +01:00
ndossche de8c44e683 [ci skip] Skip test for MSAN 2026-10-27 20:36:09 +01:00
ndossche 0c2f56bedf Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GOST and Snefru digests of 512 MiB or more
2026-10-24 10:55:52 +02:00
ndossche 509a3f63e3 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GOST and Snefru digests of 512 MiB or more
2026-10-24 10:55:47 +02:00
ndossche 8f6512d3f2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GOST and Snefru digests of 512 MiB or more
2026-10-24 10:55:20 +02:00
Martin Mirchev 89f4d82157 Fix GOST and Snefru digests of 512 MiB or more
The bit counter update in PHP_GOSTUpdate() and PHP_SNEFRUUpdate() set the
low word one too high when it wrapped, and added at most one carry to the
high word per update. Snefru also computed the bit length of a single
update in 32 bits. The encoded message length, and thus the digest, was
wrong for inputs of 2^29 bytes or more. Compute the counter with 64-bit
arithmetic.

Closes GH-24555.
2026-10-24 10:54:51 +02:00
Ilija Tovilo 9705fda1bb Merge branch 'PHP-8.6' into master
* PHP-8.6:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:34:56 +02:00
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
Jorg Sowa 6885c8ea7f Merge branch 'PHP-8.6' into master 2026-10-19 12:12:47 +02:00
Jorg Sowa 286bc3cb1c Merge branch 'PHP-8.5' into PHP-8.6 2026-10-19 12:12:46 +02:00
Jorg Sowa a2d7bd6151 Merge branch 'PHP-8.4' into PHP-8.5 2026-10-19 12:12:43 +02:00
Jorg Sowa 17f94f0a4c Fix xxh64 seed deprecation emitted when no seed is given
Closes GH-24412
2026-10-19 12:12:37 +02:00
Shivam Mathur 8100adb5b5 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix v142 ARM64 hash and floating point results (#24317)
2026-10-14 18:09:04 +05:30
Shivam Mathur fa077a2c00 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix v142 ARM64 hash and floating point results (#24317)
2026-10-14 18:08:55 +05:30
Shivam Mathur 9dc727adcd Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix v142 ARM64 hash and floating point results (#24317)
2026-10-14 18:08:40 +05:30
Shivam Mathur 83b2eca149 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix v142 ARM64 hash and floating point results (#24317)
2026-10-14 18:08:32 +05:30
Shivam Mathur 3813c09293 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix v142 ARM64 hash and floating point results (#24317)
2026-10-14 18:08:24 +05:30
Shivam Mathur 03e959375b Fix v142 ARM64 hash and floating point results (#24317) 2026-10-14 18:07:59 +05:30
Marc Bennewitz f5d89c8394 Fix mhash_keygen_s2k() $length truncation to int (#23951)
A $length above INT_MAX was truncated to int before the range check,
so e.g. 2**32 + 16 silently returned 16 bytes. Throw a ValueError instead.
2026-09-27 23:48:58 +02:00
Weilin Du 1765f68547 Merge branch 'PHP-8.4' into PHP-8.5
Propagate the backport of PR #23770 from PHP-8.4 to PHP-8.5.

* PHP-8.4:
  Backport: fix integer overflow in mhash_keygen_s2k (#23770)
2026-09-22 01:53:26 +08:00
jvoisin eb33623c78 Backport: fix integer overflow in mhash_keygen_s2k (#23770)
Backport PR #23770 from master to PHP-8.4.
Original commit: 5e021664d8

Closes #23770
2026-09-22 01:53:25 +08:00
Jordi Kroon 3036712be9 tree: Add #[\SensitiveParameter] to more functions taking secrets (#23782)
* ext/sodium: add SensitiveParameter to missing functions

* ext/phar: add SensitiveParameter to missing functions

* ext/snmp: add SensitiveParameter to missing functions

* ext/sqlite3: add SensitiveParameter to missing functions

* ext/hash: add SensitiveParameter to missing functions
2026-09-21 12:19:04 +01:00
Julien Voisin 5e021664d8 Fix a non-exploitable integer overflow in mhash_keygen_s2k (#23770) 2026-09-19 19:10:58 +02: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
Louis-ArnaudandNickSdot df2090a393 ext/hash: report argument #2 ($filename) for null bytes in hash_file() (#23534)
php_hash_do_hash() hardcodes argument index 1 in the isfilename branch,
so hash_file() blames $algo for a null byte carried by $filename.
hash_file() is the only caller passing isfilename = 1, and its filename
is argument #2; php_hash_do_hash_hmac() already uses 2 for the same
check.

Co-authored-by: NickSdot <32384907+NickSdot@users.noreply.github.com>
2026-09-02 07:28:59 +01:00
David Carlier 759829bc2f Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/hash: Fix buffer overflow in hash_pbkdf2() with a large output length
2026-09-01 19:32:51 +01:00
David Carlier fbef051534 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/hash: Fix buffer overflow in hash_pbkdf2() with a large output length
2026-09-01 19:32:43 +01:00
Lazizbek Ergashev 13f5c4bda2 ext/hash: Fix buffer overflow in hash_pbkdf2() with a large output length
hash_pbkdf2() sized the digest buffer with ceil((float) length / 2.0) and
the block count with ceil((float) digest_length / (float) ops->digest_size).
A float carries 24 bits of mantissa, so past 2^24 the conversion rounds and
both counts come out wrong: rounding up makes zend_bin2hex() write past the
end of the return string, rounding down leaves the tail of the string
uninitialized. hash_pbkdf2('md5', 'password', 'salt', 1, 268435473) writes
8 bytes out of bounds under ASAN.

Both counts are exact in integer arithmetic, so this replaces them with
round-up divisions, which also avoids the signed overflow with an output
length of PHP_INT_MAX. <math.h> had no other user in the file.

Close GH-23380
2026-09-01 19:32:38 +01:00
NickSdot aa8b895315 ext/hash: cleaned up test (#23041) 2026-08-07 13:05:14 +01:00
NickSdot 1da3a6398b Applied fixers to improve test robustness to extensions with no code owners (#23018)
* ext/bz2: applied fixers to improve test robustness

* ext/calendar: applied fixers to improve test robustness

* ext/exif: applied fixers to improve test robustness

* ext/fileinfo: applied fixers to improve test robustness

* ext/filter: applied fixers to improve test robustness

* ext/ftp: applied fixers to improve test robustness

* ext/hash: applied fixers to improve test robustness

* ext/iconv: applied fixers to improve test robustness

* ext/ldap: applied fixers to improve test robustness

* ext/pcre: applied fixers to improve test robustness

* ext/posix: applied fixers to improve test robustness

* ext/readline: applied fixers to improve test robustness

* ext/shmop: applied fixers to improve test robustness

* ext/snmp: applied fixers to improve test robustness

* ext/sodium: applied fixers to improve test robustness

* ext/sqlite3: applied fixers to improve test robustness

* ext/sysvmsg: applied fixers to improve test robustness

* ext/sysvsem: applied fixers to improve test robustness

* ext/sysvshm: applied fixers to improve test robustness

* ext/tidy: applied fixers to improve test robustness

* ext/tokenizer: applied fixers to improve test robustness

* ext/zend_test: applied fixers to improve test robustness

* ext/zlib: applied fixers to improve test robustness
2026-08-04 13:10:07 +01:00
Weilin Du 22a6f169f2 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-22935: Make php_hash.h includable from C++ code (#22940)
2026-07-31 00:10:15 +08:00
Weilin Du 4ff84aaffa Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-22935: Make php_hash.h includable from C++ code (#22940)
2026-07-31 00:08:00 +08:00
Weilin Du a96f6ff2c7 Fix GH-22935: Make php_hash.h includable from C++ code (#22940) 2026-07-31 00:02:51 +08: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
Weilin Du 6bc7c26cf6 Replace dependencies on /ext/hash in various extensions (#21832)
Followup-PR for #21724. Using the new API in #21724 to replace dependencies
on /ext/hash in

- ext/opcache/ZendAccelerator/
- ext/soap/php_http.c
- Zend/zend_system_id.c

In the following ext, there are independent implementation of bin2hex. This PR
also change them to directly using the new Zend API.

- ext/standard/string.c
- ext/hash/php_hash.h
2026-07-09 20:03:34 +08:00
Jorg Adam Sowa 39b66bae33 Use zend_hash_find_ptr_lc() for case-insensitive name lookups (#22565)
A number of call sites lowercased a class/function/method name into a
temporary string solely to use it as a lookup key in the class table,
function table, module registry, etc., then released it. Replace those
with zend_hash_find_ptr_lc() / zend_hash_str_find_ptr_lc(), which
lowercase into a stack buffer (for short names), perform the lookup, and
free the temporary internally.

This removes the manual tolower + release boilerplate at 17 sites and
avoids a heap allocation for the common short-name case. No behavior
change.
2026-07-03 00:53:33 +01:00
Ilia Alshanetsky 81f09e8cf0 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-18173: ext/hash relies on implementation-defined malloc alignment
2026-06-29 10:37:55 -04:00
Ilia Alshanetsky 6c1b05c429 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-18173: ext/hash relies on implementation-defined malloc alignment
2026-06-29 10:37:47 -04:00
Ilia Alshanetsky 8da53b5d31 Fix GH-18173: ext/hash relies on implementation-defined malloc alignment
XXH3_state_t requires 64-byte alignment for its acc, customSecret, and
buffer members, but php_hash_alloc_context() used ecalloc(), which only
guarantees alignof(max_align_t) (typically 16 bytes on x86_64). When heap
layout broke that assumption, xxhash's aligned loads segfaulted. Add a
context_align field to php_hash_ops; when set, php_hash_alloc_context()
over-allocates and manually aligns the returned pointer, storing the offset
for php_hash_free_context() to recover the original allocation.

Fixes GH-18173
Closes GH-21668
2026-06-29 10:37:14 -04:00
henderkes 915318ed9c make all static extensions use TSRMG_STATIC
Closes GH-22277
2026-06-26 14:18:52 +02:00
Weilin Du 7c86d86d26 Reuse existing Zend parameter error helpers for standard error paths (#22033)
Cleaning up the manually constructed standard parameter errors to use existing Zend helpers in bulk. This enhance readability and align with how those errors have been thrown in most places.
2026-06-13 15:20:38 +08:00
Tim Düsterhus 5212b816d2 zend_objects: Make old_object a const* in zend_objects_clone_members() (#22089)
* zend_objects: Make `old_object` a `const*` in `zend_objects_clone_members()`

* tree-wide: Make the original object `const` in `clone_obj` handlers
2026-05-19 14:16:03 +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 03d95760c3 license-update: ext/hash source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Alexandre Daubois 11a95749b1 Convert more zend_parse_parameters_none() to fast ZPP (#21330) 2026-03-04 14:07:46 +01:00
Peter Kokot f17c5ad83b Windows build: Add new function CHECK_HEADER() (#21191)
The current function `CHECK_HEADER_ADD_INCLUDE()` automatically defines
`HAVE_<HEADER_NAME_H>` preprocessor macros, which makes it difficult to
sync with other build systems. Specially, if some `HAVE_` macro is used
in the code and this function defines this macro but Autotools doesn't.

The new `CHECK_HEADER()` function behaves similar except it doesn't
define the `HAVE_<HEADER_NAME_H>` preprocessor macro.

This removes the following unused compile definitions:

HAVE_ARGON2_H
HAVE_AVIF_H
HAVE_BZLIB_H
HAVE_CAPSTONE_CAPSTONE_H
HAVE_CURL_EASY_H
HAVE_DB_H
HAVE_DECODE_H
HAVE_DEPOT_H
HAVE_EDITLINE_READLINE_H
HAVE_ENCHANT_H
HAVE_ENCODE_H
HAVE_FFI_H
HAVE_FIREBIRD_INTERFACE_H
HAVE_FT2BUILD_H
HAVE_GD_H
HAVE_GLIB_H
HAVE_GMP_H
HAVE_HTTPD_H
HAVE_IBASE_H
HAVE_IR_IR_H
HAVE_KECCAKHASH_H
HAVE_LBER_H
HAVE_LDAP_H
HAVE_LIBEXSLT_EXSLT_H
HAVE_LIBINTL_H
HAVE_LIBPQ_FE_H
HAVE_LIBTIDY_TIDY_H
HAVE_LIBXML_PARSER_H
HAVE_LIBXML_TREE_H
HAVE_LIBXML_XMLWRITER_H
HAVE_LIBXSLT_XSLT_H
HAVE_LMDB_H
HAVE_MBSTRING_H
HAVE_MYSQL_H
HAVE_ONIGURUMA_H
HAVE_OPENSSL_SSL_H
HAVE_PNG_H
HAVE_SNMP_H
HAVE_SODIUM_H
HAVE_SQLITE3_H
HAVE_SQLITE3EXT_H
HAVE_SYBFRONT_H
HAVE_TIDY_H
HAVE_TIDY_TIDY_H
HAVE_TIDYBUFFIO_H
HAVE_TIMELIB_CONFIG_H
HAVE_UNICODE_USPOOF_H
HAVE_UNICODE_UTF_H
HAVE_XPM_H
HAVE_ZIP_H
HAVE_ZIPCONF_H
HAVE_ZLIB_H

The following compile definitions are defined explicitly:

- HAVE_ICONV_H
- HAVE_MSCOREE_H
- HAVE_SQL_H
- HAVE_SQLEXT_H

Additionally, the `SETUP_OPENSSL()` function doesn't accept the 6th
argument anymore.
2026-03-03 20:06:40 +01:00