Commit graph

127812 commits

Author SHA1 Message Date
Niels Dossche
40a1a86f0c
Fix module shutdown crash during ZTS JIT shutdown
Commit a21195650e fixed a leak by adding a TSRM destructor for the
JIT globals in ZTS mode. In case the main thread shuts down the TSRM, it
will call all the destructors. The JIT globals destructor will be
invoked, but will always access the main thread globals using JIT_G.
This means that instead of freeing the JIT globals in the different
threads, the one in the main thread is freed repeatedly over and over,
crashing PHP. Fix it by always passing the pointer instead of relying on
JIT_G.

Closes GH-10835.

(cherry picked from commit b3e28e2290)
2023-03-14 20:41:08 +01:00
Dmitry Stogov
18b43d2950 Fix Zend/tests/type_declarations/variance/class_order_autoload1.phpt
test failre introduced by 44e5c04e55

This ASSERT-ion path was never reached becuase of the bug fixed by
44e5c04e55. It's possible in case of
circular class dependencies that may resolved by __autoload().
Unfortunately these circular dependencies can't be stored in the
inheritace cahce.
2023-02-28 22:57:52 +03:00
Niels Dossche
0f21cbc57c Fix GH-10715: phpdbg heap buffer overflow -- by misuse of the option "--run"
Fixes GH-10715

When a string starting with a NUL character is passed to
phpdbg_vprint(), the vasprintf() will return that 0 characters have been
printed. This causes msglen == 0. When phpdbg_process_print() is called
with a message of length 0, the -1 to check for '\n' will perform an out
of bounds read. Since nothing is printed anyway for msglen == 0, it
seems best to just skip the printing routine for this case.

Closes GH-10720.
2023-02-27 19:47:55 +00:00
Dmitry Stogov
44e5c04e55 Fix incorrect inheritance cache update (#10719) 2023-02-27 21:47:29 +03:00
George Peter Banyard
adc5edd411
Fixed ValueError message in count_chars()
The value of the mode argument must be between 0 and 4 inclusive, not 1 and 4.
2023-02-26 14:27:46 +00:00
George Peter Banyard
2133970152
Fixed ValueError message in substr_compare()
It used some random argument name instead of
2023-02-26 14:25:02 +00:00
George Peter Banyard
6a5b3f0ff9
The userland constants do not start with PHP_ 2023-02-26 14:18:12 +00:00
Niels Dossche
b09be29ac1 Fix incorrect error checking in php_openssl_set_server_dh_param()
SSL_CTX_set_tmp_dh() and SSL_CTX_set0_tmp_dh_pkey() return 1 on success
and 0 on error. But only < 0 was checked which means that errors were
never caught.

Closes GH-10705.
2023-02-26 08:17:14 +00:00
Niels Dossche
eb7bb3430b Fix format string mistake in accel_move_code_to_huge_pages()
inode is unsigned, so use %lu instead of %ld
2023-02-26 08:12:57 +00:00
Niels Dossche
df579adac7 Fix GH-10692: PHP crashes on Windows when an inexistent filename is executed
Fixes GH-10692

php_fopen_primary_script() does not initialize all fields of
zend_file_handle. So when it fails and when fastcgi is true, the
zend_destroy_file_handle() function will try to free uninitialized
pointers, causing a segmentation fault. Fix it by zero-initializing file
handles just like the zend_stream_init_fp() counterpart does.

Closes GH-10697.
2023-02-25 14:32:55 +00:00
Ilija Tovilo
7d2b01eea7
[skip ci] Add github reference to bug fix in NEWS 2023-02-24 20:44:47 +01:00
Niels Dossche
b9a5bfc355
Fix GH-10570: Assertion `(key)->h != 0 && "Hash must be known"' failed.
Fixes GH-10570, see GH-10570 for analysis.

Closes GH-10572
2023-02-24 20:40:29 +01:00
nielsdos
8959ff39d8 Fix incorrect type for return value of zend_update_static_property_ex()
zend_update_static_property_ex() returns a zend_result, but the return
value is stored here in a bool. A bool is unsigned on my system, so in
case zend_update_static_property_ex() returns FAILURE (== -1) this gets
converted to 1 instead. This is not a valid zend_result value. This
means that (transitive) callers could mistakingly think the function
succeeded while it did in fact not succeed. Fix it by changing the type
to zend_result.

Closes GH-10691.
2023-02-24 17:02:32 +00:00
Pierrick Charron
91db3a1b85
Fixed bug GH-10270 Unable to return CURL_READFUNC_PAUSE in readfunc callback
Closes GH-10607

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-24 14:32:23 +00:00
George Peter Banyard
5f357f341d
Fix GH-10672 (pg_lo_open segfaults in the strict_types mode)
We need to use the proper ZPP qualifier for zend_string

Closes GH-10677
2023-02-24 14:31:23 +00:00
Daniil Gentili
8d1c0a1403
Fix segfault when using ReflectionFiber (fixes #10439)
Closes GH-10478
2023-02-23 23:20:27 +01:00
Danack
939c546ea1
Re-enable UnixODBC testing.
The problem installing the package in the CI environment has been fixed.
2023-02-23 23:14:02 +01:00
Niels Dossche
c510083c8c Fix incorrect string length for output_handler in zlib ini code
The length of "output_handler" is supposed to be passed, but as sizeof
is used, the resulting number includes the NUL character, so the length
is off-by-one. Subtract one to pass the correct length.

Closes GH-10667.
2023-02-23 18:47:26 +00:00
Kévin Dunglas
c4c861b01a make clean: remove ext/opcache/minilua
Closes GH-10656.
2023-02-21 21:24:16 +00:00
NathanFreeman
0a466e7ad8 Fix GH-10647: Spoofchecker isSuspicious/areConfusable methods
error code's argument.

Closes GH-10653.
2023-02-21 21:00:49 +00:00
nielsdos
da3ce6015d Propagate errors correctly in ps_files_cleanup_dir()
In SessionHandler::gc, we use a virtual call to PS(default_mod)->s_gc to
call the gc implementation. That return value is checked against
FAILURE (-1).
One of the call targets of PS(default_mod)->s_gc is ps_gc_files().
ps_gc_files() calls to ps_files_cleanup_dir(). The latter function has
some error checks and outputs a notice if something goes wrong. In cases
of errors, the function returns 0. This means that the check in
SessionHandler::gc will misinterpret this as a success and report that 0
files have been *successfully* cleaned up. Fix it by returning -1 to
indicate something *did* go wrong.

Closes GH-10644.
2023-02-21 16:09:22 +00:00
nielsdos
74c880edd1
Fix Tidy tests failing due to different spelling
On my system, with Tidy 5.7.45, I get the following error diff for two
tests:
002+ line 1 column 7 - Error: <asd> is not recognised!
002- line 1 column 7 - Error: <asd> is not recognized!

As we can see, the spelling of recognised is different. Use an EXPECTF
and %c to mitigate this issue.

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 14:32:39 +00:00
ndossche
8cac8306c3
Fix incorrect error check in browsecap for pcre2_match()
pcre2_match() returns error codes < 0, but only the "no match" error
code was handled. Fix it by changing the check to >= 0.

Closes GH-10632

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 14:13:13 +00:00
ndossche
f592f75e9c
Add missing error check on tidyLoadConfig
Parse errors were not reported for the default config, they were only
reported when explicitly another config was loaded.
This means that users may not be aware of errors in their configuration
and therefore the behaviour of Tidy might not be what they intended.
This patch fixes that issue by using a common function. In fact, the
check for -1 might be enough for the current implementation of Tidy, but
the Tidy docs say that any value other than 0 indicates an error.
So future errors might not be caught when just using an error code of -1.
Therefore, this also changes the error code checks of == -1 to < 0 and
== 1 to > 0.

Closes GH-10636

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 14:12:17 +00:00
Max Kellermann
ed4dc39e7f
ext/curl/interface: fix zend_result return value
Closes GH-10640

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 13:41:07 +00:00
Max Kellermann
d51eb1d74c
Zend/zend_ini: fix zend_result return values
The value "1" was illegal.

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 13:40:54 +00:00
Dmitry Stogov
70ff10af72
Fix GH-10635: ARM64 function JIT causes impossible assertion (#10638) 2023-02-21 09:25:51 +03:00
Dmitry Stogov
08e7591206 Fix (at lease part of the) #GH-10635: ARM64 function JIT causes impossible assertion 2023-02-20 19:42:35 +03:00
Niels Dossche
ed0c0df351
Fix GH-10627: mb_convert_encoding crashes PHP on Windows
Fixes GH-10627

The php_mb_convert_encoding() function can return NULL on error, but
this case was not handled, which led to a NULL pointer dereference and
hence a crash.

Closes GH-10628

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-20 13:33:11 +00:00
Max Kellermann
243865ae57
ext/mbstring: fix new_value length check
Commit 8bbd0952e5 added a check rejecting empty strings; in the
merge commiot 379d9a1cfc however it was changed to a NULL check,
one that did not make sense because ZSTR_VAL() is guaranteed to never
be NULL; the length check was accidently removed by that merge commit.

This bug was found by GCC's -Waddress warning:

 ext/mbstring/mbstring.c:748:27: warning: the comparison will always evaluate as ‘true’ for the address of ‘val’ will never be NULL [-Waddress]
   748 |         if (!new_value || !ZSTR_VAL(new_value)) {
       |                           ^

Closes GH-10532

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-20 13:32:56 +00:00
Niels Dossche
ae16471628 Fix GH-10623: ReflectionFunction::getClosureUsedVariables() returns empty array in presence of variadic arguments
The code was missing the handling for the RECV_VARIADIC instruction.
Additional regression test for GH-10623

Co-authored-by: Fabio Ivona <fabio.ivona@defstudio.it>
2023-02-19 20:18:28 +00:00
Jakub Zelenka
a9e4f51844
Update NEWS with scanner and parser build fixes 2023-02-17 16:37:14 +00:00
Jakub Zelenka
4f731fa2ec
Fix php_json_scanner_defs.h target in ext/json/Makefile.frag 2023-02-17 16:37:14 +00:00
Daniel Black
2b3fa5edac
zend win32 RE2C header files to Make targets and generated_files
like zend_ini_parser.h, list zend_ini_scanner_defs.h and
zend_language_scanner_defs.h.

Add all these files to generated_files so they don't get missed.
2023-02-17 16:37:14 +00:00
Daniel Black
e83cda0887
ext/Zend: zend_language_scanner_defs.h as make target 2023-02-17 16:37:13 +00:00
Daniel Black
2fde3afffb
ext/json: add php_json_scanner_defs.h as make target
To prevent build failures like:

make: *** No rule to make target '/code/master/ext/json/php_json_scanner_defs.h', needed by 'ext/json/json_scanner.lo'.  Stop.
2023-02-17 16:37:13 +00:00
Ilija Tovilo
52c96f21be
[skip ci] Skip slow tidy test on asan 2023-02-17 14:56:28 +01:00
Jakub Zelenka
fd3cc17cbd
Add max_multipart_body_parts info into php.ini files 2023-02-17 13:21:18 +00:00
Ilija Tovilo
7b68ff46da
Revert "Fix GH-10168: heap-buffer-overflow at zval_undefined_cv"
This reverts commit 71ddede565.
2023-02-16 14:07:17 +01:00
Ben Ramsey
d9ac59b0a9
Ensure tar is not bsdtar 2023-02-14 14:13:01 -06:00
Ben Ramsey
843ba82b53
Use gtar if it's in the PATH 2023-02-14 13:49:02 -06:00
Ben Ramsey
586e81b259
Point to the issue tracker on GitHub 2023-02-14 13:49:02 -06:00
Tim Düsterhus
5e69d76bbc
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] Next release will be 8.0.29
2023-02-14 20:27:53 +01:00
Niels Dossche
e35e6dc351
[ci skip] NEWS (#10586) 2023-02-14 20:27:29 +01:00
Gabriel Caruso
0e45ed772d
[ci skip] Next release will be 8.0.29 2023-02-14 15:19:11 +01:00
Remi Collet
b11d855dbf
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  more config for new FPM tests
2023-02-14 14:14:03 +01:00
Remi Collet
e86d8704b4
more config for new FPM tests 2023-02-14 14:13:40 +01:00
Jakub Zelenka
4058d20608
Merge branch 'PHP-8.0' into PHP-8.1 2023-02-14 10:52:17 +00:00
Jakub Zelenka
937b1e38e2
Fix missing colon in NEWS 2023-02-14 10:46:48 +00:00
Jakub Zelenka
eef29d434a
Change NEWS for GHSA-54hq-v5wp-fqgv as it is for all SAPIs 2023-02-14 10:42:40 +00:00