Commit Graph

132255 Commits

Author SHA1 Message Date
Niels Dossche
fba659abb9
Fix GHSA-g665-fm4p-vhff: OOB access in ldap_escape 2024-11-20 11:06:12 +01:00
Jakub Zelenka
d7fe40868e
Fix GHSA-c5f2-jwm7-mmq2: stream HTTP fulluri CRLF injection 2024-11-20 11:06:02 +01:00
Niels Dossche
7a25e7728d
Fix GHSA-5hqh-c84r-qjcv: Integer overflow in the firebird quoter causing OOB writes 2024-11-20 11:05:55 +01:00
Niels Dossche
4a79a5a59a
Fix GHSA-5hqh-c84r-qjcv: Integer overflow in the dblib quoter causing OOB writes 2024-11-20 11:05:48 +01:00
Dmitry Stogov
ef5844a1ca
Use the immutable twin of temporary op_array (#16861) 2024-11-19 20:55:15 +03:00
Patrick Allaert
27a9965b97
Merge branch 'PHP-8.1' into PHP-8.2 2024-11-19 16:11:41 +01:00
Dmitry Stogov
6167c64782
Backport JIT fix: set valid EX(opline) before calling gc_possible_root() (#16858) 2024-11-19 18:03:54 +03:00
Niels Dossche
fc1db70f10
Fix GH-16630: UAF in lexer with encoding translation and heredocs
zend_save_lexical_state() can be nested multiple times, for example for
the parser initialization and then in the heredoc lexing. The input
should not be freed if we restore to the same filtered string.

Closes GH-16716.
2024-11-18 19:58:02 +01:00
Jakub Zelenka
a001ad33f0
Update NEWS with security fixes info 2024-11-18 16:56:00 +01:00
Jakub Zelenka
32f905f1d6 Fix MySQLnd possible buffer over read in auth_protocol 2024-11-18 16:55:44 +01:00
Jakub Zelenka
cae2582416
Run labeler only in php/php-src repository
Closes GH-16844
2024-11-18 16:43:15 +01:00
Dmitry Stogov
71403558d3
Fixed test 2024-11-18 15:34:55 +03:00
Dmitry Stogov
79aaeeafe5
Fix GH-16829: Segmentation fault with opcache.jit=tracing enabled on aarch64 2024-11-18 14:27:08 +03:00
Niels Dossche
7dd336ae83
Fix GHSA-4w77-75f9-2c8w 2024-11-18 11:06:01 +01:00
Niels Dossche
81030c9bbb
Fix GHSA-r977-prxv-hc43
Move the bound check upwards. Since this doesn't generate output we can
check the bound first.
2024-11-17 19:30:44 +01:00
Jakub Zelenka
2f5aa9f9d1
Fix GHSA-h35g-vwh6-m678: Mysqlnd - various heap buffer over-reads
This fixes issues causing buffer over-read that leak heap content:
- RESP packet field default left over for COM_LIST
- RESP packet upsert filename
- OK packet message
- RESP packet for stmt row data
  - ps_fetch_from_1_to_8_bytes
  - ps_fetch_float
  - ps_fetch_double
  - ps_fetch_time
  - ps_fetch_date
  - ps_fetch_datetime
  - ps_fetch_string
  - ps_fetch_bit
- RESP packet for query row data (just possible overflow on 32bit)

It also adds various protocol tests using a new fake server.
2024-11-17 19:30:13 +01:00
Niels Dossche
f9ecf90070
Fix GHSA-g665-fm4p-vhff: OOB access in ldap_escape 2024-11-17 19:29:56 +01:00
Jakub Zelenka
426a6d4539
Fix GHSA-c5f2-jwm7-mmq2: stream HTTP fulluri CRLF injection 2024-11-17 19:29:45 +01:00
Niels Dossche
69c5f68fdc
Fix GHSA-5hqh-c84r-qjcv: Integer overflow in the firebird quoter causing OOB writes 2024-11-17 19:29:26 +01:00
Niels Dossche
d9baa9fed8
Fix GHSA-5hqh-c84r-qjcv: Integer overflow in the dblib quoter causing OOB writes 2024-11-17 19:29:16 +01:00
David Carlier
80894d87d5
Fix GH-16834: cal_from_jd overflow on julian_day argument.
close GH-16836
2024-11-17 12:27:02 +00:00
Niels Dossche
fbb0061993
Fix GH-16808: Segmentation fault in RecursiveIteratorIterator->current() with a xml element input
When the current data is invalid, NULL must be returned. At least that's
how the check in SPL works and how other extensions do this as well.
If we don't do this, an UNDEF value gets propagated to a return value
(misprinted as null); leading to issues.

Closes GH-16825.
2024-11-16 13:39:46 +01:00
Niels Dossche
553d79c709
Fix GH-16799: Assertion failure at Zend/zend_vm_execute.h:7469
zend_is_callable_ex() can unfortunately emit a deprecation, and then
a user error handler can throw an exception. This causes an assert
failure at ZEND_VM_NEXT_OPCODE(). We fix this by checking if there's an
exception after zend_is_callable_ex().

Closes GH-16803.
2024-11-15 20:02:26 +01:00
Christoph M. Becker
f725f504e8
Adapt ext/intl tests for ICU 75.1 and 76.1
Closes GH-16788.
2024-11-15 18:55:01 +01:00
Christoph M. Becker
fe1925aaac
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Update FreeBSD CI
2024-11-15 18:21:59 +01:00
Christoph M. Becker
85e23dbbb2
Update FreeBSD CI
FreeBSD 13.2 is no longer supported[1], and apparently the respective
Cirrus CI image has been removed.  We update to FreeBSD 13.3.

This also requires to disable some compiler warnings now, and adapt a
test case.

[1] <https://www.freebsd.org/security/#sup>
[2] <https://github.com/php/php-src/runs/33044888209>

Co-authored-by: David Carlier <devnexen@gmail.com>

Closes GH-16817.
2024-11-15 18:20:48 +01:00
Christoph M. Becker
3abb031c3c
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Stick with icu4c 74.2 on macOS CI for PHP-8.1
2024-11-15 14:25:19 +01:00
Christoph M. Becker
9128fb8f1e
Stick with icu4c 74.2 on macOS CI for PHP-8.1
PHP-8.1 is not ready for ICU >= 75.1 which requires C++17 support.
Thus we force the usage of icu4c@74, what is scheduled for removal in
May 2025, though.

Closes GH-16789.
2024-11-15 14:24:24 +01:00
Niels Dossche
cbb3b9371d
Fix GH-16770: Tracing JIT type mismatch when returning UNDEF
When returning an UNDEF value, it actually becomes NULL.
The following code took this into account:
28344e0445/ext/opcache/jit/zend_jit_trace.c (L2196-L2199)

But the stack does not update the type to NULL, causing a mismatch.

Closes GH-16784.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2024-11-14 22:33:06 +01:00
Christoph M. Becker
c69fdef760
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Need to define BREW_OPT
2024-11-13 21:23:56 +01:00
Christoph M. Becker
d6249b6e1f
Need to define BREW_OPT
This is only defined as of PHP-8.4; alternatively we could also inline
the `brew --prefix` call, but that makes it harder for upward merges.

Closes GH-16785.
2024-11-13 21:23:27 +01:00
Christoph M. Becker
45487c6ec2
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Patch libcurl.pc for macOS builds
2024-11-13 19:38:07 +01:00
Christoph M. Becker
9196a72eb0
Patch libcurl.pc for macOS builds
cURL 8.11.0 added a couple of packages to `Requires.private`, but these
packages are irrelevant when building against a shared libcurl.  For
some reason, these private requirements are checked when we're doing
`pkg-config --cflags` (that happens with the preinstalled pkg-config
0.29.2, as well as with pkgconf 2.3.0).  To avoid further messing with
these packages, we just drop the `Requires.private` line from
libcurl.pc.

See GH-16741 for more details.

Closes GH-16783.
2024-11-13 19:36:58 +01:00
David Carlier
4124b04e34
Fix GH-16771: imagecreatefromstring overflow on invalid format.
close GH-16776
2024-11-13 12:48:37 +00:00
Dmitry Stogov
19809a526b
Fix incorrect handling of ZEND_ACC_FINAL flag in JIT (#16778) 2024-11-13 14:38:54 +03:00
Niels Dossche
02ee521e20
Fix GH-16727: Opcache bad signal 139 crash in ZTS bookworm (frankenphp)
Reproducer: https://github.com/php/php-src/issues/16727#issuecomment-2466256317

The root cause is a data race between two different threads:

1) We allocate a lower cased name for an anonymous class here:
   f97353f228/Zend/zend_compile.c (L8109)
2) This gets looked up as an interned string here:
   f97353f228/Zend/zend_compile.c (L8112)
   Assuming that there are uppercase symbols in the string and therefore
   `lcname != name` and that `lcname` is not yet in the interned string table,
   the pointer value of `lcname` won't change.
3) Here we add the string into the interned string table:
   f97353f228/Zend/zend_compile.c (L8223)
   However, in the meantime another thread could've added the string into the interned string table.
   This means that the following code will run, indirectly called via the `LITERAL_STR` macro,
   freeing `lcname`: 62e53e6f49/ext/opcache/ZendAccelerator.c (L572-L575)
4) In the reproducer we then access the freed `lcname` string here:
   f97353f228/Zend/zend_compile.c (L8229)

This is solved in my patch by retrieving the interned string pointer
and putting it in `lcname`.

Closes GH-16748.
2024-11-11 16:20:05 +01:00
Gina Peter Banyard
1b379f5e55
ext/hash: Fix GH-16711: Segfault in mhash()
Closes GH-16713
2024-11-10 20:15:44 +00:00
Gina Peter Banyard
fc8f30d312
ext/hash: Add failing tests for GH-16711 2024-11-10 20:14:21 +00:00
Niels Dossche
d87f3ff662
[ci skip] Add credit for test 2024-11-09 17:09:35 +01:00
Niels Dossche
72c0222926
Fix GH-16695: phar:// tar parser and zero-length file header blocks
There are two issues:
1) There's an off-by-one in the check for the minimum file size for a
   tar (i.e. `>` instead of `>=`).
2) The loop in the tar parsing parses a header, and then unconditionally
   reads the next one. However, that doesn't necessarily exist.
   Instead, we remove the loop condition and check for the end of the
   file before reading the next header. Note that we can't use
   php_stream_eof as the flag may not be set yet when we're already at
   the end.

Closes GH-16700.
2024-11-09 17:07:53 +01:00
Hans Krentel (hakre)
c075546320
Fail early in *nix configuration build script
Adding two exit early safeguards in the *nix configuration build script:

1) Given the initial cd into the build tree fails (the project root),
   the `buildconf` script exits with non-zero status (failure).
2) Given the grep command does not exist or `configure.ac` AC_INIT [1]
   expectations are unmet, the buildconf script exits non-zero.

Additionally quoting the pathname to cd into and the empty CD_PATH
parameter for portability, also for systems that are using a
non-portable pathname [2] for the build tree.

The initial CD safeguard has been applied to the `buildconf` and
four more scripts:

- build/genif.sh
- scripts/dev/credits
- scripts/dev/genfiles
- scripts/dev/makedist

Rationale:

Cd-ing into the project root should always prematurely exit w/ FAILURE
as a required precondition for its invocation has not been met. This
should never go unnoticed as it always requires user intervention.

Similar and more specifically to the PHP build on *nix systems, the
grep command is required early to obtain the `php_extra_version` from
configure.ac.  Previously, if the grep command is missing (or failing
due to not matching the line with the AC_INIT macro [1]), the internal
dev parameter would always be zero (0) which can easily result in the
situation that the configure script is not being rebuilt. This is
cumbersome as the rebuild of a configure script is more likely required
with checked-out dev versions under change rather than an already
properly set-up build environment on a dedicated build or release
system. Missing the fact that either the grep utility is missing or
the expectation of having the AC_INIT macro in configure.ac is unmet
should never go unnoticed as it always requires user intervention.

[1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Initializing-configure.html
[2]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_271

Closes GH-16717.
2024-11-09 14:03:04 +01:00
Niels Dossche
994e866cf2
Fix memory leak in php_openssl_pkey_from_zval()
Closes GH-16691.
2024-11-09 10:58:44 +01:00
Niels Dossche
2f4f09f7e6
Fix various memory leaks related to openssl exports
Closes GH-16692.
2024-11-09 10:58:17 +01:00
Niels Dossche
ac8d0e57d9
Prevent unexpected array entry conversion when reading key
When passing an array, the key entry can get converted to a string if it
is an object, but this actually modifies the original array entry.
The test originally outputted:

```
array(2) {
  [0]=>
  string(...) => ...
  [1]=>
  string(0) ""
}
```

This is unexpected. Use zval_try_get_string() to prevent this behaviour.

Closes GH-16693.
2024-11-09 10:57:50 +01:00
Jakub Zelenka
065bde1e13
Fix GH-16432: PHP-FPM 8.2 SIGSEGV in fpm_get_status 2024-11-08 16:44:05 +01:00
David Carlier
875a9dc4c4
Fix introduced leaks from GH-15715.
Choosing here to shrink the requested allocation to its max value.
2024-11-08 12:27:03 +00:00
Christoph M. Becker
03eeec16f0
Fix rename_variation12*.phpt parallel test conflicts
For rename_variation12.phpt this is actually not necessary, since there
is no rename_variation11.phpt, but we still fix it to be in sync with
rename_variation12-win32.phpt which actually is prone to parallel
conflicts.

(cherry picked from commit d4263ddc40)
2024-11-08 00:24:49 +01:00
David Carlier
e74e66e3f7
Fix oss-fuzz report triggered by GH-15712 commit.
It triggered allocation overflow which, even fixed, in turn gives memory
leak on 32 bits but the allocator relies on signed integers.

close GH-15915
2024-11-07 22:51:05 +00:00
Christoph M. Becker
d276ea54f4
Skip tests if ldap_set_rebind_proc() is not available
This is already done by ldap_set_rebind_proc_error.phpt, but not by the
other two affected tests.

Closes GH-16708.
2024-11-07 13:22:17 +01:00
David Carlier
fde053bb92
Fix GH-16235 jdtogregorian overflow
close GH-16242
2024-11-06 12:52:32 +00:00