1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Commit Graph

134940 Commits

Author SHA1 Message Date
Ilija Tovilo
c5745f40a5 Fix array to string conversion warning emitted in optimizer
Fixes GH-16408
Closes GH-16380
2024-10-14 13:24:05 +02:00
Niels Dossche
34e635f366 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16409: Segfault in exif_thumbnail when not dealing with a real file
2024-10-13 21:12:46 +02:00
Niels Dossche
3843f0ecfe Fix GH-16409: Segfault in exif_thumbnail when not dealing with a real file
Closes GH-16416.
2024-10-13 21:12:17 +02:00
David Carlier
47c81462b8 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-13 14:26:47 +01:00
David Carlier
d70b7811b0 ext/gmp: gmp_pow fix FPE with large values.
even without sanitizers, it is reproducible but with the following

```
<?php
$g = gmp_init(256);
var_dump(gmp_pow($g, PHP_INT_MAX));
```

we get this

```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==286922==ERROR: AddressSanitizer: FPE on unknown address 0x03e8000460ca (pc 0x7faf6c69de5c bp 0x400000000000004 sp 0x7ffe9843c740 T0)
    #0 0x7faf6c69de5c in __pthread_kill_implementation nptl/pthread_kill.c:44
    #1 0x7faf6c649c81 in __GI_raise ../sysdeps/posix/raise.c:26
    #2 0x7faf6db9386c in __gmp_exception (/lib/x86_64-linux-gnu/libgmp.so.10+0xd86c) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #3 0x7faf6db938d3 in __gmp_overflow_in_mpz (/lib/x86_64-linux-gnu/libgmp.so.10+0xd8d3) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #4 0x7faf6dbac95c in __gmpz_realloc (/lib/x86_64-linux-gnu/libgmp.so.10+0x2695c) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #5 0x7faf6dba9038 in __gmpz_n_pow_ui (/lib/x86_64-linux-gnu/libgmp.so.10+0x23038) (BuildId: 1af68a49fe041a5bb48a2915c3d47541f713bb38)
    #6 0x5565ae1ccd9f in zif_gmp_pow /home/dcarlier/Contribs/php-src/ext/gmp/gmp.c:1286
    #7 0x5565aee96ea9 in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:1312
    #8 0x5565af144320 in execute_ex /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:56075
    #9 0x5565af160f07 in zend_execute /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:60439
    #10 0x5565aed6fafe in zend_execute_scripts /home/dcarlier/Contribs/php-src/Zend/zend.c:1842
    #11 0x5565aeae70a8 in php_execute_script /home/dcarlier/Contribs/php-src/main/main.c:2578
    #12 0x5565af532f4e in do_cli /home/dcarlier/Contribs/php-src/sapi/cli/php_cli.c:964
    #13 0x5565af535877 in main /home/dcarlier/Contribs/php-src/sapi/cli/php_cli.c:1334
    #14 0x7faf6c633d67 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #15 0x7faf6c633e24 in __libc_start_main_impl ../csu/libc-start.c:360
    #16 0x5565adc04040 in _start (/home/dcarlier/Contribs/php-src/sapi/cli/php+0x2604040) (BuildId: 949049955bdf8b7197390b1978a1dfc3ef6fdf38)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE nptl/pthread_kill.c:44 in __pthread_kill_implementation
==286922==ABORTING
```
2024-10-13 14:26:29 +01:00
David Carlier
f31232e218 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-13 14:19:33 +01:00
David Carlier
84a8fea251 Fix GH-16290: session cookie_lifetime ini value overflow.
close GH-16295
2024-10-13 14:19:18 +01:00
Christoph M. Becker
631c04e690 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16326: Memory management is broken for bad dictionaries
2024-10-13 02:29:22 +02:00
Christoph M. Becker
d94be24f30 Fix GH-16326: Memory management is broken for bad dictionaries
We must not `efree()` `zend_string`s, since they may have a refcount
greater than one, and may even be interned.

We also must not confuse `zend_string *` with `zend_string **`.

And we should play it safe by using `safe_emalloc()` to avoid
theoretical integer overflows.

We also simplify a bit, according to suggestions of @TimWolla.

Closes GH-16335.
2024-10-13 02:28:07 +02:00
Ilija Tovilo
5c8f42f05c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Mark some more macOS tests as flaky
2024-10-13 02:07:11 +02:00
Ilija Tovilo
b6ca871396 [skip ci] Mark some more macOS tests as flaky 2024-10-13 02:06:57 +02:00
Niels Dossche
6ff4a2d7a8 Fix GH-16318: Recursive array segfaults soap encoding
This adds recursion protection to the array encoders.

Closes GH-16347.
2024-10-12 23:20:15 +02:00
Christoph M. Becker
41d75f42ec Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16388: UB when freeing a cloned _ZendTestFiber
2024-10-12 22:48:46 +02:00
Christoph M. Becker
a3eb1fd86d Fix GH-16388: UB when freeing a cloned _ZendTestFiber
Since there is no need to clone instances of this test class, we
prevent cloning in the first place.

Closes GH-16400.
2024-10-12 22:48:11 +02:00
David Carlier
f12e496cba Merge branch 'PHP-8.2' into PHP-8.3 2024-10-12 15:23:35 +01:00
David Carlier
e583890af0 Fix socket_recvfrom overflow on buffer size.
when passing PHP_INT_MAX for the $length param we get this (with ubsan)

`ext/sockets/sockets.c:1409:36: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int'`

close GH-16382
2024-10-12 15:23:03 +01:00
Christoph M. Becker
76a819e7d1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16357: openssl may modify member types of certificate arrays
2024-10-12 16:06:44 +02:00
Christoph M. Becker
549bcdb7fb Fix GH-16357: openssl may modify member types of certificate arrays
We must not use `try_convert_to_string()` on members of unseparated
array arguments; instead of separating, we use `zval_try_get_string()`.

Closes GH-16370.
2024-10-12 16:05:31 +02:00
Niels Dossche
3d9e55c42d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix error message for newer libxml
  Backport 061058a9: Test fixes for libxml2 2.12.0
  Workaround deprecation warning in zend_test on 8.1
  Backport 3ec5919e: Update error message for libxml 2.13
  Backport f74f9b07: Update libxml test for the directory field behaviour change
  Backport 4fe82131: Backport libxml2 2.13.2 fixes (#14816)
  Backport e2d97314: Backport deprecation warning ignores to unbreak CI
  Backport 0a39890c: Fix libxml2 2.12 build due to API breaks
2024-10-12 15:14:14 +02:00
Niels Dossche
2554640804 Merge remote-tracking branch 'upstream/PHP-8.1' into PHP-8.2
* upstream/PHP-8.1:
  Fix error message for newer libxml
  Backport 061058a9: Test fixes for libxml2 2.12.0
  Workaround deprecation warning in zend_test on 8.1
  Backport 3ec5919e: Update error message for libxml 2.13
  Backport f74f9b07: Update libxml test for the directory field behaviour change
  Backport 4fe82131: Backport libxml2 2.13.2 fixes (#14816)
  Backport e2d97314: Backport deprecation warning ignores to unbreak CI
  Backport 0a39890c: Fix libxml2 2.12 build due to API breaks
2024-10-12 15:14:02 +02:00
Niels Dossche
2c40762b4e Fix error message for newer libxml
Normally I would backport 3354cc6e, but this doesn't apply cleanly due
to observer changes.
2024-10-12 15:12:40 +02:00
Niels Dossche
14c107371c Backport 061058a9: Test fixes for libxml2 2.12.0 2024-10-12 15:12:40 +02:00
Niels Dossche
5bd04acfe9 Workaround deprecation warning in zend_test on 8.1 2024-10-12 15:12:40 +02:00
Niels Dossche
6199289b6e Backport 3ec5919e: Update error message for libxml 2.13
External entity loading got its error level decreased in upstream,
which means they now map to E_NOTICE. Also the error message format has
changed.
2024-10-12 15:12:40 +02:00
Niels Dossche
b78618750f Backport f74f9b07: Update libxml test for the directory field behaviour change
See https://gitlab.gnome.org/GNOME/libxml2/-/issues/753.
The base directory for the entity is no longer set, follow the upstream
behaviour.
2024-10-12 15:12:40 +02:00
Niels Dossche
bb46b4b799 Backport 4fe82131: Backport libxml2 2.13.2 fixes (#14816)
Backproted from https://github.com/php/php-src/pull/14789
2024-10-12 15:12:40 +02:00
Niels Dossche
dbde99d875 Backport e2d97314: Backport deprecation warning ignores to unbreak CI
In master I use ZEND_DIAGNOSTIC_IGNORED_START, but that doesn't exist on
8.2 or 8.3 (8.3 has a similar macro though).
So to unbreak CI I just made a variation of this directly in the
php_libxml.h header.

See 683e787860 (commitcomment-134301083)
2024-10-12 15:12:40 +02:00
Niels Dossche
fa6a0f80f6 Backport 0a39890c: Fix libxml2 2.12 build due to API breaks
See https://github.com/php/php-src/actions/runs/7062192818/job/19225478601
2024-10-12 15:12:40 +02:00
Niels Dossche
3ed01d454d Add missing hierarchy checks to replaceChild
You can break the hierarchy for attribute nodes, use the helper function
introduced recently [1] to fix this issue.

[1] 066d18f2

Closes GH-16377.
2024-10-12 13:32:13 +02:00
Niels Dossche
6902e196c3 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16337: Use-after-free in SplHeap
2024-10-12 13:31:50 +02:00
Niels Dossche
a56ff4fec7 Fix GH-16337: Use-after-free in SplHeap
We introduce a new flag to indicate when a heap or priority queue is
write-locked. In principle we could've used SPL_HEAP_CORRUPTED too, but
that won't be descriptive to users (and it's a lie too).

Closes GH-16346.
2024-10-12 13:31:23 +02:00
Niels Dossche
a1f7ce5617 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16385: Unexpected null returned by session_set_cookie_params
2024-10-12 13:09:06 +02:00
Niels Dossche
7cdd1302c3 Fix GH-16385: Unexpected null returned by session_set_cookie_params
Two issues:
1) The check happened before ZPP checks
2) The `return;` statement caused NULL to be returned while this
   function can only return booleans. An exception seems not acceptable
   in stable versions, but a warning may do.

Closes GH-16386.
2024-10-12 13:08:37 +02:00
Christoph M. Becker
382cd2f067 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Backport 3237b8f471
2024-10-11 23:56:48 +02:00
Christoph M. Becker
e8ef81a9b1 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Backport 3237b8f471
2024-10-11 23:56:19 +02:00
Saki Takamachi
8497400b23 Backport 3237b8f471
This should fix the PDO_OCI and oci8 test failures due to more verbose
output of Oracle DB 23.5.

Closes GH-16107.
2024-10-11 23:55:50 +02:00
David Carlier
d612b0a124 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-11 19:38:26 +01:00
David Carlier
f2859a4050 Fix GH-16322: imageaffine overflow on affine argument.
close GH-16334
2024-10-11 19:37:34 +01:00
David Carlier
89b4f94024 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-11 08:48:49 +01:00
David Carlier
c34d4fbbf4 Fix GH-16360 mb_substr overflow on start and length arguments.
occurs when they are negated to start working from the end instead
when set with ZEND_LONG_MIN.
2024-10-11 08:46:48 +01:00
Niels Dossche
e4a23e920d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16168: php 8.1 and earlier crash immediately when compiled with Xcode 16 clang on macOS 15
2024-10-11 09:14:10 +02:00
Niels Dossche
e2e2b3ab62 Fix GH-16168: php 8.1 and earlier crash immediately when compiled with Xcode 16 clang on macOS 15
The inline assembly uses labels with the prefix `.L`. On Linux systems
this is the local label prefix. It appears that macOS uses `L` as a
local prefix, which means that the prefix used in the inline assembly is not
local for macOS systems [1].
When combined with inlining, this causes the compiler to get confused
and merge a part of the inline assembly between different functions,
causing control flow to jump from one function to another function.
This is avoided on PHP 8.2 and up by the fact that it
uses `zend_never_inline NOIPA`, but nothing guarantees that compiler
changes won't affect this as well.

To solve this issue, we instead use local labels. These will make the
compiler pick the correct prefix, preventing the issue.

Additionally, while here, we also change the computation of `delta`.
It is undefined behaviour to compute the pointer difference between
two different objects. To circumvent this, we cast first to `uintptr_t`.

This change is cleanly backportable to 8.1 for vendors to pick up.

[1] https://github.com/php/php-src/issues/16168#issuecomment-2404792553

With the help of investigation and testing of @ryandesign.

Closes GH-16348.
2024-10-11 09:09:05 +02:00
Niels Dossche
5ae792715e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16316: DOMXPath breaks when not initialized properly
2024-10-10 19:28:53 +02:00
Niels Dossche
1d0fbdf449 Fix GH-16316: DOMXPath breaks when not initialized properly
Closes GH-16330.
2024-10-10 19:28:20 +02:00
Christoph M. Becker
80477b15cf Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Allow to run push workflows manually
2024-10-10 02:13:19 +02:00
Christoph M. Becker
509fec8ee6 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Allow to run push workflows manually
2024-10-10 02:12:26 +02:00
Christoph M. Becker
0b5167cff5 [skip ci] Allow to run push workflows manually
As is, we're running the push workflow for all pushes and pull request,
plus we run more comprehensive nightly workflow for all branches which
had commits during the day.  That means that security branches may not
run CI for weeks or even months.  In the meantime, dependencies might
be updated, which can cause later workflow runs to fail.  For instance,
a few openssl tests fail due to security fixes in OpenSSL[1], an update
of Oracle Instant Client causes a couple of oci8 and pdo_oci tests to
fail[2], and the macOS builds do no longer even built (investigation
pending).

Therefore, we allow to run the pull workflow manually, so it is
possible to check the CI condition of temporary inactive branches from
time to time.

[1] <https://github.com/php/php-src/pull/16097>
[2] <https://github.com/php/php-src/pull/16107>

Closes GH-16148.
2024-10-10 02:11:59 +02:00
Christoph M. Becker
5c6fc09e45 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16174: Empty string is an invalid expression for phpdbg-ev
2024-10-10 01:46:30 +02:00
Christoph M. Becker
6bcba24eb0 Fix GH-16174: Empty string is an invalid expression for phpdbg-ev
Strings may be empty, so we must not assume they are not.

Closes GH-16177.
2024-10-10 01:45:37 +02:00
Christoph M. Becker
b36170fde8 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Revert "Fix GH-16322: overflow on imageaffine matrix argument."
2024-10-10 01:14:18 +02:00