Commit graph

131445 commits

Author SHA1 Message Date
Max Kellermann
c7637ed1c0 Zend/zend_type_code: remove hard-coded integer values and
remove unused macro ZEND_SAME_FAKE_TYPE
Zend/zend_variables: add _Static_assert on the size zend_rc_dtor_func
_Static_assert is C11, but has been supported since GCC 4.6.

Also removing the comment about keeping those values in sync with
`zend_variables.c` which was obsoleted by commit 0460420205
(designated initializers).

Closes GH-10714.
2023-02-27 20:52:17 +00:00
David Carlier
3db32439f9 Merge branch 'PHP-8.2' 2023-02-27 19:49:01 +00:00
David Carlier
4c2db35b05 Merge branch 'PHP-8.1' into PHP-8.2 2023-02-27 19:48:13 +00: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
9d9b8bad47 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect inheritance cache update (#10719)
2023-02-27 21:47:55 +03:00
Dmitry Stogov
db7358ccc9 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect inheritance cache update (#10719)
2023-02-27 21:47:46 +03:00
Dmitry Stogov
44e5c04e55 Fix incorrect inheritance cache update (#10719) 2023-02-27 21:47:29 +03:00
Dmitry Stogov
c7a9190124 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect inheritance cache update (#10719)
2023-02-27 21:39:53 +03:00
Dmitry Stogov
2e3fc8c0ff
Fix incorrect inheritance cache update (#10719) 2023-02-27 21:39:18 +03:00
Bob Weinand
81abd8dc37 Allow gen_stub.php to parse and ignore extended docblock types
Extended docblock types, according to psalm or phpstan conventions may include array shapes, callable signatures etc.. These are now ignored by ignoring any nested parenthesized expression (followed by optional :type) at the end of the type.
2023-02-27 17:30:28 +01:00
Niels Dossche
edacfbd1d4
Remove unnecessary checks in ftp_fopen_wrapper.c (#10711)
* resource is always non-NULL at this point because we check for NULL
  right after its creation.
* resource->path is always set at this point because of the check right
  above the code where it's used. It was also confusing to see "/" being
  considered as a "default".
2023-02-27 13:20:37 +00:00
Max Kellermann
371ae12d89 Zend/zend_fibers: change return value to zend_result
According to @nikic:

> The current guideline for use of bool and zend_result in php-src is
> that bool is an appropriate return value for "is" or "has" style
> functions, which return a yes/no answer. zend_result is an
> appropriate return value for functions that perform some operation
> that may succeed or fail.

Closes GH-10622.
2023-02-26 15:07:08 +00:00
George Peter Banyard
81e59c6497
Improve handling of XML options
Mark boolean options as such
Warn on invalid types
Stubs info

Closes GH-10675
2023-02-26 14:34:39 +00:00
George Peter Banyard
524391bcf6
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fixed ValueError message in count_chars()
  Fixed ValueError message in substr_compare()
  The userland constants do not start with PHP_
2023-02-26 14:28:49 +00:00
George Peter Banyard
f440911057
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fixed ValueError message in count_chars()
  Fixed ValueError message in substr_compare()
  The userland constants do not start with PHP_
2023-02-26 14:28:22 +00: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
Max Kellermann
02690fe3c0 Zend/zend_types.h: move zend_string to zend_string.h
It is now possible to include only `zend_string.h` without
`zend_types.h`.
2023-02-26 14:16:53 +00:00
Max Kellermann
42577c6b6b Zend/zend_types.h: move zend_uchar.h to zend_char.h
Prepare to fix the cyclic header dependency from `zend_string.h`.
2023-02-26 14:16:53 +00:00
Max Kellermann
eb34c28fed Zend/zend_types.h: move zend_refcounted to zend_refcounted.h
This is necessary for splitting `zend_types.h` further.
2023-02-26 14:16:53 +00:00
Max Kellermann
b98f18e7c3 Zend/zend_type_code.h: convert to enum 2023-02-26 14:16:53 +00:00
Max Kellermann
0270a1e54c Zend/zend_types.h: move IS_* to zend_type_code.h
More decoupling of circular header dependencies.
2023-02-26 14:16:53 +00:00
Max Kellermann
e509a66a9c Zend/zend_rc_debug: convert ZEND_RC_MOD_CHECK() to function
This allows using `ZEND_RC_MOD_CHECK()` without including any additional
headers.  Performance is not relevant here because this is a
debug-only feature.

The `zend_refcounted_h` forward declaration is necessary to break a
circular header dependency.
2023-02-26 14:16:53 +00:00
Max Kellermann
d6e95041e2 Zend/zend_types.h: move zend_rc_debug to zend_rc_debug.h
`zend_rc_debug` is not a type and does not really belong in
`zend_types.h`; this allows using `ZEND_RC_MOD_CHECK()` without
including the huge `zend_types.h` header and allows decoupling
circular header dependencies.
2023-02-26 14:16:53 +00:00
Niels Dossche
9108a32bfe
Minor cleanups in Zend execution APIs (#10699)
* Remove always-false check in zend_lookup_class_ex()

This check is always false because of the undefined behaviour rule that
says a NULL pointer must never be dereferenced: we already dereference name
when checking the cache slot, before the NULL check. So the NULL may be
optimised away by the compiler. It looks like the code isn't even
supposed to work with name being NULL, so just remove the check.

* Remove always-true check in zend_fetch_static_property_address_ex()

* Simplify always-true conditions
2023-02-26 14:15:04 +00:00
Marcos Marcolin
9004725367
chore: standardize the visibility of functions. (#10708)
Co-authored-by: Marcos Marcolin <marcos@ixcsoft.com.br>
2023-02-26 14:08:33 +00:00
Niels Dossche
07fe46fb5d
Simplify checks and returns in ext/xmlwriter (#10701)
* The ptr check is redundant because XMLWRITER_FROM_OBJECT will return
  if ptr is NULL.
* Use RETURN_BOOL to simplify the return code.
2023-02-26 14:07:55 +00:00
George Peter Banyard
382148d7bb
Fix UBSAN warning about applying zero offset to null pointer (#10700)
vpath may be NULL here so check for it before trying to add 0 (the length of the vpath) to it.
2023-02-26 14:06:30 +00:00
Niels Dossche
375e7402af
Change implicit enum return value checks to explicit checks (#10703) 2023-02-26 08:56:20 +00:00
Niels Dossche
f0cfebc2b8 Use zend_result where appropriate in ext/openssl
Remove dead code

s is always NULL, so the check is always false.

Closes GH-10704.
2023-02-26 08:28:23 +00:00
David Carlier
c54948378d Merge branch 'PHP-8.2' 2023-02-26 08:19:05 +00:00
David Carlier
bf2e778c71 Merge branch 'PHP-8.1' into PHP-8.2 2023-02-26 08:18:09 +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
othercorey
e1967ca9ed
Change DOMCharacterData::appendData return type to true (#10690) 2023-02-25 21:42:10 +00:00
George Peter Banyard
7c44baa334
[skip ci] Add comments as to why no ZPP union type format is used 2023-02-25 17:16:03 +00:00
David Carlier
0c0b41d875 Merge branch 'PHP-8.2' 2023-02-25 14:36:56 +00:00
David Carlier
7638640529 Fix GH-10659: hash/xxhash applying build upstream fix
ref: 6189ecd3d4

replacing the C++ compile time assert for C11 one.

Closes GH-10693.
2023-02-25 14:36:35 +00:00
David Carlier
a890b0ba73 Merge branch 'PHP-8.2' 2023-02-25 14:33:59 +00:00
David Carlier
bf68d10bb4 Merge branch 'PHP-8.1' into PHP-8.2 2023-02-25 14:33:11 +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
Niels Dossche
dcc3255b18
Fix GH-10489: run-tests.php does not escape path when building cmd (#10560)
Multiple tests had to be changed to escape the arguments in shell
commands. Some tests are skipped because they behave differently with
spaces in the path versus without. One notable example of this is the
hashbang test which does not work because spaces in hashbangs paths are
not supported in Linux.

Co-authored-by: Michael Voříšek <mvorisek@mvorisek.cz>
2023-02-25 14:02:06 +00:00
Ilija Tovilo
b14785ca85
Merge branch 'PHP-8.2'
* PHP-8.2:
  [skip ci] Add github reference to bug fix in NEWS
2023-02-24 20:46:11 +01:00
Ilija Tovilo
c9bd540bac
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [skip ci] Add github reference to bug fix in NEWS
2023-02-24 20:45:31 +01:00
Ilija Tovilo
7d2b01eea7
[skip ci] Add github reference to bug fix in NEWS 2023-02-24 20:44:47 +01:00
Ilija Tovilo
3a602d235c
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10570: Assertion `(key)->h != 0 && "Hash must be known"' failed.
2023-02-24 20:42:00 +01:00
Ilija Tovilo
9b10b65e2b
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10570: Assertion `(key)->h != 0 && "Hash must be known"' failed.
2023-02-24 20:41:40 +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
David Carlier
ad7d3c888d Merge branch 'PHP-8.2' 2023-02-24 17:03:50 +00:00