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

139808 Commits

Author SHA1 Message Date
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
Niels Dossche
afc1f0d99b Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17216: Trampoline crash on error
2024-12-21 00:26:37 +01:00
Niels Dossche
627432785e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17216: Trampoline crash on error
2024-12-21 00:26:23 +01:00
Niels Dossche
2c3b56ded0 Fix GH-17216: Trampoline crash on error
The error handling is incomplete on argument cleanup.
1. The fci is not cleared which means that zend_free_trampoline() is
   never called.
2. The cleaning for extra named arguments was missing, resulting in
   memory leak.

Closes GH-17219.
2024-12-21 00:25:06 +01:00
David CARLIER
c4bb6e6c39 ext/sockets: further timeout handling changes. (#17210)
close GH-17210
2024-12-20 22:36:14 +00:00
Arnaud Le Blanc
420365d922 Merge branch 'PHP-8.4'
* PHP-8.4:
  Add observer temporary to dl'ed functions
2024-12-20 18:52:43 +01:00
Arnaud Le Blanc
32148e9b10 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add observer temporary to dl'ed functions
2024-12-20 18:50:16 +01:00
Arnaud Le Blanc
9e7932b292 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add observer temporary to dl'ed functions
2024-12-20 18:46:55 +01:00
Arnaud Le Blanc
6f579934f0 Add observer temporary to dl'ed functions
When observer is enabled, we normally add an extra temporary to all
functions, to store the previously observed frame. However, this is done in
zend_observer_post_startup() so it doesn't happen to dl'ed() functions.

One possible fix would be to move that from zend_observer_post_startup()
to zend_register_functions(), but this would be too early: Observer may
not be enabled when zend_register_functions() is called, and may still be
enabled later.

However, when zend_register_functions() is called at run-time (during dl()),
we know definitively whether observer is enabled.

Here I update zend_register_functions() to add a temporary to dl'ed()
functions when observer is enabled.

Fixes: GH-17211
Closes: GH-17220
2024-12-20 18:45:34 +01:00
David Carlier
76ade7165e Merge branch 'PHP-8.4' 2024-12-20 15:09:59 +00:00
David Carlier
aa815f32ae Merge branch 'PHP-8.3' into PHP-8.4 2024-12-20 15:09:49 +00:00
David Carlier
16c0e57530 Fix GH-14709 overflow on recurrences for DatePeriod::__construct
close GH-14710
2024-12-20 15:03:47 +00:00
Dmitry Stogov
ac2b656a13 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17190: Assertion failure ext/opcache/jit/ir/ir_gcm.c (#17221)
2024-12-20 11:02:41 +03:00
Dmitry Stogov
f8d2e00964 Fix GH-17190: Assertion failure ext/opcache/jit/ir/ir_gcm.c (#17221) 2024-12-20 10:59:33 +03:00
Arnaud Le Blanc
4b1c3cf0b6 Merge branch 'PHP-8.4'
* PHP-8.4:
  NEWS for GH-17168
  ext/gettext/config.m4: symlink en_US.UTF-8 test bits to en_US for musl
  ext/gettext/tests: fix libintl return values under musl
  ext/gettext/gettext.c: handle NULLs from bindtextdomain()
2024-12-19 18:39:27 +01:00
Arnaud Le Blanc
73857e66d2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  NEWS for GH-17168
  ext/gettext/config.m4: symlink en_US.UTF-8 test bits to en_US for musl
  ext/gettext/tests: fix libintl return values under musl
  ext/gettext/gettext.c: handle NULLs from bindtextdomain()
2024-12-19 18:38:30 +01:00
Arnaud Le Blanc
a23ecc0a75 NEWS for GH-17168 2024-12-19 18:30:17 +01:00
Dmitry Stogov
6a015491a0 Merge branch 'PHP-8.4'
* PHP-8.4:
  Update IR
2024-12-19 20:30:05 +03:00
Dmitry Stogov
33c12e0776 Update IR
IR commit: 79483000c2a4b918221fa3097ca47b48b3519447
2024-12-19 20:29:35 +03:00
Michael Orlitzky
471e94ce61 ext/gettext/config.m4: symlink en_US.UTF-8 test bits to en_US for musl
The gettext() family of functions under musl does not support codeset
suffixes like ".UTF-8", because the only codeset it understands is
UTF-8. (Yes, it is annoying that it doesn't support the suffix for the
codeset that it does understand; no, I am not in charge.) Thanks to
this, we have six failing tests on musl,

  * FAIL Gettext basic test with en_US locale that should be on nearly
    every system
    [ext/gettext/tests/gettext_basic-enus.phpt]

  * FAIL Test if bindtextdomain() returns string id if no directory path
    is set( if directory path is 'null')
    [ext/gettext/tests/gettext_bindtextdomain-cwd.phpt]

  * FAIL Test dcgettext() functionality
    [ext/gettext/tests/gettext_dcgettext.phpt]

  * FAIL Test dgettext() functionality
    [ext/gettext/tests/gettext_dgettext.phpt]

  * FAIL Test if dngettext() returns the correct translations
    (optionally plural).
    [ext/gettext/tests/gettext_dngettext-plural.phpt]

  * FAIL Test ngettext() functionality
    [ext/gettext/tests/gettext_ngettext.phpt]

These are all fixed by symlinking the en_US.UTF-8 message data to en_US,
where musl is able to find it.

This does not make the situation any better for developers (who don't
know what libc their users will be running), but that problem is
inhereted from C and is not the fault of the gettext extension.

This partially addresses GH #13696
2024-12-19 18:26:35 +01:00
Michael Orlitzky
bfb0e367f2 ext/gettext/tests: fix libintl return values under musl
Musl has two quirks that are leading to failed internationalization
tests. First is that the return value of bindtextdomain(..., NULL)
will always be false, rather than an "implementation-defined default
directory," because musl does not have an implementation-defined
default directory. One test needs a special case for this.

Second is that the musl implementation of bind_textdomain_codeset()
always returns NULL. The POSIX-correctness of this is debatable, but
it is roughly equivalent to correct, because musl only support UTF-8,
so the NULL value indicating that the codeset is unchanged from the
locale's codeset (UTF-8) is accurate.

PHP's bind_textdomain_codeset() function however treats NULL as
failure, unconditionally:

  * https://github.com/php/doc-en/issues/4311
  * https://github.com/php/php-src/issues/17163

This unfortunately causes false to be returned consistently on musl --
even when nothing unexpected has happened -- and naturally this is
affecting several tests. For now we change two tests to accept "false"
in addition to "UTF-8" so that they may pass on musl. If PHP's
bind_textdomain_codeset() is updated to differentiate between NULL and
NULL-with-errno-set, these tests can also be updated once again to
reject the NULL-with-errno result.

This partially addresses GH #13696
2024-12-19 18:26:35 +01:00