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

139828 Commits

Author SHA1 Message Date
Niels Dossche
23ccd06ede Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17187: unreachable program point in zend_hash
2024-12-27 15:54:42 +01:00
Niels Dossche
575ee23bd9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17187: unreachable program point in zend_hash
2024-12-27 15:54:37 +01:00
Niels Dossche
b621b3a00f Fix GH-17187: unreachable program point in zend_hash
A bunch of different issues:
1) The referenced value is copied without incrementing the refcount.
   The reason the refcount isn't incremented is because otherwise
   the array modifications would violate the RC1 constraints.
   Solve this by copying the reference itself instead and always
   read the referenced value.
2) No type checks on the array data, so malicious scripts could
   cause type confusion bugs.
3) Potential overflow when the arrays resize and we access ctag.

Closes GH-17205.
2024-12-27 15:51:17 +01:00
David Carlier
00fe9b205c ext/sockets: socket_create_listen() check port value beforehand.
port is a 16 bit field, limited to the 65535 value then.
Note that 0 is a valid case for ephemeral port.

close GH-17281
2024-12-27 14:29:11 +00: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
Niels Dossche
55afe8bd9b Implement GH-15680: Enhance zend_dump_op_array to Properly Represent Non-Printable Characters in String Literals
Replaces GH-15730 as that PR became stale.

But instead of introducing a new helper, reuse
smart_str_append_escaped(), this also removes the dependency on
ext/standard.

Closes GH-15730.
Closes GH-17277.
2024-12-27 12:53:02 +01:00
Kamil Tekiela
f0554477ae Make PDO_MYSQL_ATTR_DIRECT_QUERY a proper alias (#16935) 2024-12-26 22:26:40 +00:00
David Carlier
63e4e08e0d ext/sockets: following-up on GH-16842, update FreeBSD TCP stack setting.
- `TCP_FUNCTION_ALIAS`: fetches the function pointer name alias (>= 14.0
  only tough).
- `TCP_BBR_ALGORITHM`: set/get the underlying algorithm (0: netflix, 1:
  google) when the BBR's TCP stack is used.
- `TCP_REUSPORT_LB_NUMA`: set/get a NUMA domain filter on the socket.

close GH-16923
2024-12-26 20:54:14 +00:00
Niels Dossche
b09ed9a0f2 Use format string to cut off filename instead of duplicating memory
Split off from GH-17240.
2024-12-26 12:30:49 +01:00
Niels Dossche
466c8b0e03 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17257: UBSAN warning in ext/opcache/jit/zend_jit_vm_helpers.c
  Fix GH-17223: Memory leak in libxml encoding handling
2024-12-26 12:26:59 +01:00
Niels Dossche
f4fb77ed61 Fix GH-17257: UBSAN warning in ext/opcache/jit/zend_jit_vm_helpers.c
EX(opline) / opline can be stale if the IP is not stored, like in this
case on a trace enter. We always need to make sure that the opline is up
to date to make sure we don't use stale data.

Closes GH-17260.
2024-12-26 12:26:48 +01:00
Niels Dossche
956576b0b4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17223: Memory leak in libxml encoding handling
2024-12-26 12:25:08 +01:00
Niels Dossche
7be950f3f6 Fix GH-17223: Memory leak in libxml encoding handling
This was a bug in both libxml and PHP.
We follow up with the same change as done in GNOME/libxml@b3871dd138.

Changing away from `xmlOutputBufferCreateFilenameDefault` is not
possible yet because this is a stable branch and would break BC.

Closes GH-17254.
2024-12-26 12:24:06 +01:00
Niels Dossche
b4c5f4e92d Remove unused dummy_op_array (#17272)
This was introduced in b0b43e86ae for register allocation code, but is
not used anymore nowadays.
2024-12-26 11:25:41 +01:00
Christoph M. Becker
c1c6520c4f Make imagebmp_basic.phpt more resilient (GH-17265)
Checking for the exact output of most image formats is brittle; even an
otherwise change to some header field causes the output to change, even
if the image would be visually identical.

Checking for an (MD5) hash is even worse, since if the tests fails, we
have no clue for what reason.

Thus we compare the generated image against an pre-generated PNG, using
a test helper which will output a simple image diff in case of test
failure.
2024-12-25 23:15:45 +01:00
Niels Dossche
1331444822 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16013 and bug #80857: Big endian issues
2024-12-25 21:33:49 +01:00
Niels Dossche
250e0ffe90 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16013 and bug #80857: Big endian issues
2024-12-25 21:33:43 +01:00
Niels Dossche
99a14b805e Fix GH-16013 and bug #80857: Big endian issues
The FFI call return values follow widening rules.
We must widen to `ffi_arg` in the case we're handling a return value for types shorter than the machine width.
From http://www.chiark.greenend.org.uk/doc/libffi-dev/html/The-Closure-API.html:
> In most cases, ret points to an object of exactly the size of the type specified when cif was constructed.
> However, integral types narrower than the system register size are widened.
> In these cases your program may assume that ret points to an ffi_arg object.

If we don't do this, we get wrong values when reading the return values.

Closes GH-17255.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2024-12-25 21:33:14 +01:00
Christoph M. Becker
2021a58aec Reintroduce proc_open_multiplex.phpt (GH-17192)
The main intent of the test was to show the changed behavior on
Windows; previously, `stream_select()` would return immediately there,
reporting all pipes as ready; now, it only returns if at least one pipe
is actually ready.

The original test case was overspecified; of course, we cannot assume
that the pipes are ready one after the other; depending on the concrete
`select(2)` implementation and the system scheduler, minor differences
are to be expected.

Thus we relax the test expectations, and now require that not all pipes
are reported ready after a single `stream_select()` call, and that the
output contains all strings.  We also ensure that `stream_select()`
doesn't fail (for whatever reason).  And in case of the test
expectations not being met, we also output some diagnostics (most
notably the output that has already been read).
2024-12-25 17:41:31 +01:00
Christoph M. Becker
ef4fabf61f Merge branch 'PHP-8.4'
* PHP-8.4:
  Port fix for libgd bug 276
2024-12-25 16:29:43 +01:00
Christoph M. Becker
12ecdad183 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Port fix for libgd bug 276
2024-12-25 16:29:06 +01:00
Christoph M. Becker
643a77dda3 Port fix for libgd bug 276
The issue that BMP RLE occasionally swallowed some pixels[1] had been
fixed long ago in libgd, but apparently it has been overlooked to port
it to our bundled libgd.

We also introduce the test helper `test_image_equals_image()` which
compares in-memory images for equality.

[1] <https://github.com/libgd/libgd/issues/276>

Closes GH-17250.
2024-12-25 16:27:20 +01:00
Niels Dossche
48b37fe384 Merge branch 'PHP-8.4'
* PHP-8.4:
  [ci skip] Make build command for program using embed portable
2024-12-24 14:38:20 +01:00
Niels Dossche
ce322fd1f3 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [ci skip] Make build command for program using embed portable
2024-12-24 14:38:13 +01:00
Kévin Dunglas
a24eada99b [ci skip] Make build command for program using embed portable
Closes GH-17247.
2024-12-24 14:37:44 +01:00
Niels Dossche
db54a83f74 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17246: GC during SCCP causes segfault
2024-12-24 14:23:40 +01:00
Niels Dossche
e45fdd2f89 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17246: GC during SCCP causes segfault
2024-12-24 14:23:33 +01:00
Niels Dossche
df6db27580 Fix GH-17246: GC during SCCP causes segfault
This bug happens because of a nested `SHM_UNPROTECT()` sequence.
In particular:
```
unprotect memory at ext/opcache/ZendAccelerator.c:2127
protect memory at ext/opcache/ZendAccelerator.c:2160
unprotect memory at ext/opcache/ZendAccelerator.c:2164
unprotect memory at ext/opcache/jit/zend_jit_trace.c:7464
^^^ Nested
protect memory at ext/opcache/jit/zend_jit_trace.c:7591
^^^ Problem is here: it should not protect again due to the nested unprotect
protect memory at ext/opcache/ZendAccelerator.c:2191
^^^ This one should actually protect, not the previous one
```

The reason this nesting happen is because:
1. We try to include the script, this eventually calls `cache_script_in_shared_memory`
2. `zend_optimize_script` will eventually run SCCP as part of the DFA pass.
3. SCCP will try to replace constants, but can also run destructors when a partial array is destructed here:

4e9cde758e/Zend/Optimizer/sccp.c (L2387-L2389)

In this case, this destruction invokes the GC which invokes the tracing JIT,
leading to the nested unprotects.

This patch disables the GC to prevent invoking user code, as user code
is not supposed to run during the optimizer pipeline.

Closes GH-17249.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>
2024-12-24 14:22:48 +01:00
David Carlier
bf3673a415 ext/intl: TimeZone address todo to throw exceptions on error.
close GH-17215
2024-12-24 06:43:41 +00:00
Niels Dossche
4e9cde758e Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak on ZEND_FFI_TYPE_CHAR conversion failure
2024-12-23 14:23:16 +01:00
Niels Dossche
d1ed8beb2f Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak on ZEND_FFI_TYPE_CHAR conversion failure
2024-12-23 14:23:09 +01:00
Niels Dossche
a7f7e169d6 Fix memory leak on ZEND_FFI_TYPE_CHAR conversion failure
The success path frees tmp_str, but the error path does not.

Closes GH-17243.
2024-12-23 14:22:18 +01:00
Kamil Tekiela
bf5e6c5f2d SplFileObject::fwrite $length param nullable (#17242) 2024-12-23 00:54:24 +01:00
Christoph M. Becker
f6469054dc Merge branch 'PHP-8.4'
* PHP-8.4:
  Include relevant system headers before defining fallbacks
2024-12-22 16:30:45 +01:00
Christoph M. Becker
0285e9a868 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Include relevant system headers before defining fallbacks
2024-12-22 16:30:04 +01:00
Christoph M. Becker
fcbfd5a680 Include relevant system headers before defining fallbacks
Otherwise we may define the fallbacks, and later inclusion of the
system headers may attempt to redefine those.

Fixes GH-17112.
Closes GH-17129.
2024-12-22 16:27:01 +01:00
Jakub Zelenka
0aeac68063 Merge branch 'PHP-8.4' 2024-12-22 14:58:36 +01:00
Jakub Zelenka
c4c536da4c Merge branch 'PHP-8.3' into PHP-8.4 2024-12-22 14:58:08 +01:00
Jakub Zelenka
e0b79cdc5c Introduce FPM_TEST_DEBUG_FILTER env var and extend multi request tracing 2024-12-22 14:15:03 +01:00
Niels Dossche
d480c04be1 Implement cache slot optimization for XMLReader (#17232) 2024-12-22 13:01:45 +01:00
Niels Dossche
26244c7dcd Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix DOM test on higher branches
2024-12-21 12:50:08 +01:00
Niels Dossche
d2b6b64655 Fix DOM test on higher branches 2024-12-21 12:50:04 +01:00
Niels Dossche
8d39261603 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17225: NULL deref in spl_directory.c
2024-12-21 12:48:24 +01:00
Niels Dossche
a02648087a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17225: NULL deref in spl_directory.c
2024-12-21 12:47:48 +01:00
Niels Dossche
4bfe69bbc4 Fix GH-17225: NULL deref in spl_directory.c
NULL checks for the glob stream are inconsistently applied. To solve
this generally, factor it out to a helper function so it's less likely
to be forgotten in the future.

Closes GH-17231.
2024-12-21 12:46:05 +01:00
Shivam Mathur
b1220da496 ext/pdo_firebird: Fix label follow by declaration (#17229)
A label should be followed by a statement and not a declaration, else old gcc gives the following error: a label can only be part of a statement and a declaration is not a statement

To fix this we wrap the code in the switch case block in braces.
2024-12-21 16:56:53 +05:30
Niels Dossche
1fff0c05b7 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17224: UAF in importNode
2024-12-21 12:01:53 +01:00
Niels Dossche
62dc89d947 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17224: UAF in importNode
2024-12-21 12:01:48 +01:00
Niels Dossche
61615d5673 Fix GH-17224: UAF in importNode
Wrong document pointer is used for the namespace copy.

Closes GH-17230.
2024-12-21 12:01:22 +01:00