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

67884 Commits

Author SHA1 Message Date
Florian Engelhardt
3293fafa27 Add OPcache restart hook (#15590)
This hook will allow observing extensions to observe the actual OPcache restart.
2024-09-24 16:24:01 +02:00
Saki Takamachi
c5b258fedc Fix GH-15968: Avoid converting objects to strings in operator calculations. (#16021) 2024-09-24 22:33:36 +09:00
Bob Weinand
654b787ee1 Add API to exempt function from being traced in JIT (#15559)
Internally accessible via zend_jit_blacklist_function / externally via opcache_jit_blacklist.
The functionality currently only affects tracing JIT, but may be extended to other JIT modes in future.
2024-09-24 14:20:38 +02:00
Christoph M. Becker
f89eb15f72 Port libgd/libgd/pull/711 (GH-16016)
Note that this is not actually security related[1], but still a
reasonable sanity check.

"If a function be advertised to return an error code in the event of
difficulties, thou shalt check for that code, yea, even though the
checks triple the size of thy code and produce aches in thy typing
fingers, for if thou thinkest it cannot happen to me, the gods shall
surely punish thee for thy arrogance." – Henry Spencer

[1] <https://github.com/libgd/libgd/issues/697#issuecomment-2369613187>
2024-09-24 13:58:31 +02:00
Ayesh Karunaratne
99bceda0b3 ext/curl: Add CURLINFO_POSTTRANSFER_TIME_T support (GH-15849)
libcurl ref: [`CURLINFO_POSTTRANSFER_TIME_T`](https://curl.se/libcurl/c/CURLINFO_POSTTRANSFER_TIME_T.html)

`CURLINFO_POSTTRANSFER_TIME_T` is a libcurl info option that returns
the time it took to "post" the transfer. Available since libcurl 8.10.0

This value is also exposed as `posttransfer_time_us` in the
`curl_getinfo()` return value when the `$option` parameter is not
passed.
2024-09-24 13:39:07 +02:00
David Carlier
f35ad560b4 GH-12940 ext/pdo_pgsql: using PQclosePrepared to free statement resources.
PQclosePrepared allows the statement's name to be reused thus allowing
cache solutions to work properly ; whereas, for now, the `DEALLOCATE
<statement>` query is used which free entirely the statement's resources.

close GH-13316
2024-09-24 12:09:56 +01:00
Christoph M. Becker
f44250c418 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-24 12:35:06 +02:00
Christoph M. Becker
acee803e6a Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-24 12:33:17 +02:00
Christoph M. Becker
81916758ec Fix GH-15980: Signed integer overflow in main/streams/streams.c
We need to avoid signed integer overflows which are undefined behavior.
We catch that, and set `offset` to `ZEND_LONG_MAX` (which is also the
largest value of `zend_off_t` on all platforms).  Of course, that seek
may fail, but even if it succeeds, the stream is no longer readable,
but that matches the current behavior for offsets near `ZEND_LONG_MAX`.

Closes GH-15989.
2024-09-24 12:32:00 +02:00
Ayesh Karunaratne
ba748e7bb5 ext/curl: Add CURLOPT_DEBUGFUNCTION option (GH-15674)
This adds support for `CURLOPT_DEBUGFUNCTION`[^1] Curl option to set a
custom callback that gets called with debug information during the
lifetime of a Curl request.

The callback gets called with the `CurlHandle` object, an integer
containing the type of the debug message, and a string containing the
debug message. The callback may get called multiple times with the
same message type during a request.

PHP already uses `CURLOPT_DEBUGFUNCTION` functionality to internally
to expose a Curl option named `CURLINFO_HEADER_OUT`.

However,`CURLINFO_HEADER_OUT` is not a "real" Curl option supported
by libcurl. Back in 2006, `CURLINFO_HEADER_OUT` was added[^2] as
a Curl option by using the debug-callback feature. Git history does
not run that back to show why `CURLINFO_HEADER_OUT` was added as a
Curl option, and why the other debug types (such as
`CURLINFO_HEADER_IN` were not added as Curl options, but this seems
to be a historical artifact when we added features without trying
to be close to libcurl options.

This approach has a few issues:

1. `CURLINFO_HEADER_OUT` is not an actual Curl option supported by
  upstream libcurl.

2. All of the Curl options have `CURLOPT_` prefix, and `CURLINFO_HEADER_OUT`
  is the only Curl "option" that uses the `CURLINFO` prefix. This exception
  is, however, noted[^3] in docs.

3. When `CURLINFO_HEADER_OUT` is set, the `CURLOPT_VERBOSE` is also implicitly
  set. This was reported[^4] to bugs.php.net, but the bug is marked as wontfix.

This commit adds support for `CURLOPT_DEBUGFUNCTION`. It extends the existing
`curl_debug` callback to store the header-in information if it encounters
a debug message with `CURLINFO_HEADER_OUT`. In all cases, if a callable
is set, it gets called.

`CURLOPT_DEBUGFUNCTION` intends to replace `CURLINFO_HEADER_OUT` Curl
option as a versatile alternative that can also be used to extract
other debug information such as SSL data, text information messages,
incoming headers, as well as headers sent out (which `CURLINFO_HEADER_OUT`
makes available).

The callables are allowed to throw exceptions, but the return values are
ignored.

`CURLOPT_DEBUGFUNCTION` requires `CURLOPT_VERBOSE` enabled, and setting
`CURLOPT_DEBUGFUNCTION` does _not_ implicitly enable `CURLOPT_VERBOSE`.

If the `CURLOPT_DEBUGFUNCTION` option is set, setting `CURLINFO_HEADER_OUT`
throws a `ValueError` exception. Setting `CURLOPT_DEBUGFUNCTION` _after_
enabling `CURLINFO_HEADER_OUT` is allowed. Technically, it is possible
for both functionality (calling user-provided callback _and_ storing
header-out data) is possible, setting `CURLINFO_HEADER_OUT` is not
allowed to encourage the use of `CURLOPT_DEBUGFUNCTION` function.

This commit also adds the rest of the `CURLINFO_` constants used as
the `type` integer value in `CURLOPT_DEBUGFUNCTION` callback.

---

[^1]: [cur.se - CURLOPT_DEBUGFUNCTION](https://curl.se/libcurl/c/CURLOPT_DEBUGFUNCTION.html)
[^2]: [`5f25d80`](5f25d80d10)
[^3]: [curl_setopt doc mentioning `CURLINFO_` prefix is intentional](https://www.php.net/manual/en/function.curl-setopt.php#:~:text=prefix%20is%20intentional)
[^4]: [bugs.php.net - `CURLOPT_VERBOSE` does not work with `CURLINFO_HEADER_OUT`](https://bugs.php.net/bug.php?id=65348)
2024-09-24 10:56:56 +02:00
Dmitry Stogov
8f00430a2b Fix GH-15972: Assertion failure in ext/opcache/jit/zend_jit_vm_helpers.c with function JIT (#16001) 2024-09-24 10:24:08 +03:00
Calvin Buckley
07377de110 Merge branch 'PHP-8.3'
* PHP-8.3:
  Cast big endian byte shuffling to uint
2024-09-24 02:24:02 -03:00
Calvin Buckley
22d25d2896 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Cast big endian byte shuffling to uint
2024-09-24 02:23:51 -03:00
Calvin Buckley
6cef9d365e Merge branch 'phar-big-endian-8.2' into PHP-8.2
* phar-big-endian-8.2:
  Cast big endian byte shuffling to uint
2024-09-24 02:23:30 -03:00
Niels Dossche
cf0a44a38a [ci skip] Fix typo 2024-09-23 22:19:15 +02:00
Niels Dossche
90f81ca7cb [ci skip] Exchange TODO comment for an explanation
Such that nobody actually attempts to implement this.
2024-09-23 21:10:14 +02:00
Christoph M. Becker
5dd8bb0fa8 Merge branch 'PHP-8.3'
* PHP-8.3:
  ext/curl: mark certain tests as xfail on curl 8.10.0
2024-09-23 16:15:46 +02:00
Christoph M. Becker
8b35b06be5 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/curl: mark certain tests as xfail on curl 8.10.0
2024-09-23 16:14:47 +02:00
Ayesh Karunaratne
0bdc4b8c24 ext/curl: mark certain tests as xfail on curl 8.10.0
Closes GH-16007.
2024-09-23 16:14:09 +02:00
Dmitry Stogov
b2eff1f2ce Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006)
2024-09-23 17:13:47 +03:00
Dmitry Stogov
e3507cba6f Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006)
2024-09-23 17:09:17 +03:00
Dmitry Stogov
dc0987d154 Fix GH-15973: Segmentation fault in JIT mode 1135 (#16006) 2024-09-23 17:09:00 +03:00
Christoph M. Becker
5c1b945a16 Merge branch 'PHP-8.3'
* PHP-8.3:
  Mark failing curl test on macOS x64 as xfail
2024-09-23 13:36:36 +02:00
Christoph M. Becker
5961b4ad25 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Mark failing curl test on macOS x64 as xfail
2024-09-23 13:35:55 +02:00
Christoph M. Becker
fc06e0c0d8 Mark failing curl test on macOS x64 as xfail
Exactly these tests are failing on all our macOS x64 CI runners for
about a week.  For now we mark them as xfail, to get back to a green
CI pipeline.

Closes GH-16002.
2024-09-23 13:35:28 +02:00
Gina Peter Banyard
585cf9c156 ext/bcmath: null should not be supported for operator overloading & fix some comparison issues (#15875) 2024-09-23 11:49:33 +01:00
Gina Peter Banyard
b039af0120 ext/gmp: Use zend_result for type instead of int
Especially as we are widening a zend_result to int just to immediately narrow it back to a zend_result.
2024-09-23 10:55:51 +01:00
DanielEScherzer
34325c5e3a zend_assert_valid_class_name(): use double quotes around names (#15990) 2024-09-23 00:44:16 +01:00
Gina Peter Banyard
064ea9c505 Inlines the behaviour of php_mkdir_ex() into plain wrapper mkdir handler (#15520)
This effectively inlines the behaviour of php_mkdir_ex() which is a deprecated API from at least 17 years ago, and also fixes some of the return values.

This also removes a dependency on ext/standard
2024-09-23 00:40:02 +01:00
Christoph M. Becker
8a5ada4e10 Merge branch 'PHP-8.3'
* PHP-8.3:
  Revert "Fix GH-15980: Signed integer overflow in main/streams/streams.c"
2024-09-23 01:33:57 +02:00
Christoph M. Becker
a9fcf498e3 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Revert "Fix GH-15980: Signed integer overflow in main/streams/streams.c"
2024-09-23 01:32:45 +02:00
Christoph M. Becker
ee95ee7216 Revert "Fix GH-15980: Signed integer overflow in main/streams/streams.c"
This reverts commit 6a04c79e41, since the
new test case apparently fails on 64bit Linux, so this needs closer
investigation.
2024-09-23 01:31:05 +02:00
Christoph M. Becker
10008fb6e8 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-23 00:30:29 +02:00
Christoph M. Becker
c701508e6b Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15980: Signed integer overflow in main/streams/streams.c
2024-09-23 00:29:15 +02:00
Christoph M. Becker
6a04c79e41 Fix GH-15980: Signed integer overflow in main/streams/streams.c
We need to avoid signed integer overflows which are undefined behavior.
We catch that, and set `offset` to `ZEND_LONG_MAX` (which is also the
largest value of `zend_off_t` on all platforms).  Of course, after such
a seek a stream is no longer readable, but that matches the current
behavior for offsets near `ZEND_LONG_MAX`.

Closes GH-15989.
2024-09-23 00:28:09 +02:00
Saki Takamachi
f6db576c31 [RFC] ext/bcmath: Added bcdivmod (#15740)
RFC: https://wiki.php.net/rfc/add_bcdivmod_to_bcmath

Added bcdivmod() function and added divmod() method to BcMath\Number class.
2024-09-23 06:43:11 +09:00
Christoph M. Becker
2b90acb469 Fix GH-15986: Double-free due to Pdo\Pgsql::setNoticeCallback()
We need to release the fcall info cache instead of destroying it.

Closes GH-15987.
2024-09-22 23:35:05 +02:00
Calvin Buckley
792a0e6dec Cast big endian byte shuffling to uint
This works, but UBSan running on a big endian platform (in this, ppc64)
will complain that the ((uchar*)buffer)[n] is int, and shifting that
could be weird. Since the value of PHAR_GET_32 et al are almost always
unsigned, it makes sense to cast these as unsigned.

Fixes phar tests on a big endian system with UBSan enabled.
2024-09-22 15:29:50 -03:00
Daniel Scherzer
79d708cfca GH-15976: clarify error messages for enum/trait/interface/alias names
Instead of always saying that a name is reserved or deprecated and
cannot/should not be used as a class name, take the usage into account and say
the name cannot be used as an enum name, trait name, etc. In the process, for
class names add a missing "a".
2024-09-22 19:14:57 +01:00
Christoph M. Becker
0695b9773d Make ext/shmop/tests/gh14537.phpt more resilient (GH-15985)
The actual problem is our `shmget()` implementation which does not care
to set `errno` appropriately; that should be fixed, although mapping
the error conditions to those specified by POSIX might be hard.

For now, we only make the test case more resilient by ignoring the
exact error; "No error" doesn't make sense anyway.
2024-09-22 17:03:16 +02:00
Niels Dossche
5bfd45cd44 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15908 and GH-15026: leak / assertion failure in streams.c
2024-09-22 16:09:21 +02:00
Niels Dossche
94c2ae616b Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15908 and GH-15026: leak / assertion failure in streams.c
2024-09-22 16:08:51 +02:00
Niels Dossche
018c0b3d14 Fix GH-15908 and GH-15026: leak / assertion failure in streams.c
This was first reported as a leak in GH-15026, but was mistakingly
believed to be a false positive. Then an assertion was added and it got
triggered in GH-15908. This fixes the leak. Upon merging into master the
assertion should be removed as well.

Closes GH-15924.
2024-09-22 16:07:12 +02:00
Niels Dossche
27b3131422 Fix GH-15982: Assertion failure with array_find when references are involved
Closes GH-15983.
2024-09-22 14:34:55 +02:00
Saki Takamachi
05cb27a8f9 ext/bcmath: Check for scale overflow (#15741) 2024-09-22 06:59:06 +09:00
Christoph M. Becker
580435354e Support bug64159.phpt on Windows CI (GH-15895)
This test queries `extOutput` for the first line of output of the
command which was executed when snmpd started (`HexTest` in snmpd.conf).
Since there is no `/bin/sh` on Windows, no command would be run, and as
such we received an empty string.  We fix that by dynamically adjusting
snmpd.conf to run a JScript which has the same output as bigtest.

We also make the test diff more helpful in case of failures, where so
far we only would have known that the output had a different message
digest.
2024-09-21 16:03:25 +02:00
Christoph M. Becker
6f5610ccc8 Fix ext/snmp for newer net-snmp versions on Windows (GH-15888)
As of net-snmp 5.8.0, the library defines their own `(v)asprintf()` if
not available on the system.  However, PHP also does this, so when
building ext/snmp there would be conflicting declarations on Windows.
To avoid this, we explictly define `HAVE_ASPRINTF`, so net-snmp does
not redeclare when its headers are included.
2024-09-20 23:59:17 +02:00
Niels Dossche
1b171bb6b4 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15918: Assertion failure in ext/spl/spl_fixedarray.c
2024-09-20 17:34:54 +02:00
Niels Dossche
9774cedb01 Fix GH-15918: Assertion failure in ext/spl/spl_fixedarray.c
SplFixedArray should've never get supported in ArrayObject because it's
overloaded, and so that breaks assumptions. This regressed in c4ecd82f.

Closes GH-15947.
2024-09-20 17:34:23 +02:00
Niels Dossche
7e6e71255e Small optimization in dom_local_name_compare_ex() (#15950)
We can use `memcmp()` directly and skip some of the logic handling
in `zend_binary_strcmp()`. `perf record` shows a reduction for
`dom_html5_serializes_as_void()` from 3.12% to 0.77%.
2024-09-20 08:11:13 +02:00