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

140288 Commits

Author SHA1 Message Date
Christoph M. Becker
236e12e5f0 Drop --with-uncritical-warn-choke configuration option
This selection of suppressed warnings is pretty arbitrary, and
apparently disabling it does not raise any more warning for whole
php-src (except for `-Wno-deprecated-declarations`).  As such it
appears to be pretty useless, and it seems to be more appropriate to
let users select which warnings to suppress via manually set `CFLAGS`.

Since we already apply `/wd4996`[1] when building with MSVC, and there
are indeed plenty of deprecation warnings, for now, we apply
`-Wno-deprecated-declarations` for Clang builds unconditionally.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996>

Closes GH-17554.
2025-02-01 15:09:40 +01:00
Christoph M. Becker
ed92da89a9 Refactor uncompress() loop in php_handle_swc() (GH-17574)
As is, MSVC raises C4334[1] to hint at a potential code issue.  We
could solve this with a cast, but actually the code is unclear as is
because `factor` is not the factor, but rather the factor`s power.
Thus we refactor the loop variant, and also fix the comment.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4334>
2025-02-01 13:17:45 +01:00
Niels Dossche
28751d32c2 Fix nightly failure in socket_afpacket.phpt
Alpine has a slighly differently worded error message, so relax the test:

"unable to retrieve peer name [95]: Not supported"
2025-02-01 12:39:15 +01:00
Christoph M. Becker
a611be4c07 Elevate Windows CI to /W2 (sans C4146/C4244) (GH-17581)
C4146[1] is about unary minus applied to unsigned operands; that
behavior is well defined, and apparently used deliberately in the code
base.

C4244[2] is about possible loss of data when converting to another
arithmetic type.  This is addressed by another PR[3].

Anyhow, it seems like a no brainer to elevate to `/W2` even if we have
to exempt two categories of warnings, since we can catch some others.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146?view=msvc-170>
[2] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4244>
[3] <https://github.com/php/php-src/pull/17076>
2025-02-01 12:25:24 +01:00
Christoph M. Becker
64830b9b3d Reuse EG(windows_version_info) in php_get_uname() (GH-17558)
There is no need to retrieve the Windows OS version information again,
since it is already available via `EG(windows_version_info)`.
2025-02-01 11:23:53 +01:00
Christoph M. Becker
3955b01653 Avoid duplicate build rules
On Windows, the cli and phpdbg SAPIs have variants (cli-win32 and
phpdbgs, respectively) which are build by default.  However, the
variants share some files, what leads to duplicate build rules in the
generated Makefile.  NMake throws warning U4004[1], but proceeds
happily, ignoring the second build rule.  That means that different
flags for duplicate rules are ignored, hinting at a potential problem.

We solve this by introducing an additional (optional) argument to
`SAPI()` and `ADD_SOURCES()` which can be used to avoid such duplicate
build rules.  It's left to the SAPI maintainers to make sure that
appropriate rules are created.  We fix this for phpdbgs right away,
which currently couldn't be build without phpdbg due to the missing
define; we remove the unused `PHP_PHPDBG_EXPORTS` flag altogether.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/nmake-warning-u4004>

Closes GH-17545.
2025-02-01 11:21:09 +01:00
Niels Dossche
8deca2838c Fix initializer for older C compilers 2025-01-31 22:45:03 +01:00
Kalle Sommer Nielsen
ed320b500c Fix C23 syntax for VS16 (CI runs VS22) 2025-01-31 22:28:31 +02:00
Ilija Tovilo
16c9652f27 Fix use-of-uninitialized-value of EG(last_fatal_error_backtrace) with ZTS (GH-17639)
Static variables are zeroed, but ts memory is not. Hence, we need to do
it ourselves.
2025-01-31 14:14:53 +01:00
Gina Peter Banyard
b4f275f9f8 Zend: Use ZEND_FCI_INITIALIZED() macro to check if an FCI is initialized (#17291) 2025-01-31 12:10:44 +00:00
Ilija Tovilo
47b7779329 Fix return type of error_get_last()
Since GH-17056, the result may return the backtrace array.

Closes GH-17641
2025-01-31 12:11:54 +01:00
Tim Düsterhus
5052b325fe zend_execute: Fix misleading UnhandledMatchError messages when exception_string_param_max_len=0 (#17601) 2025-01-31 11:12:19 +01:00
Tim Düsterhus
8c68fe1b5c Merge branch 'PHP-8.4'
* PHP-8.4:
  zend_execute: Suppress values in `UnhandledMatchError` for `zend.exception_ignore_args=1` (#17619)
2025-01-31 10:21:49 +01:00
Tim Düsterhus
7eaa9f0478 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  zend_execute: Suppress values in `UnhandledMatchError` for `zend.exception_ignore_args=1` (#17619)
2025-01-31 10:21:32 +01:00
Tim Düsterhus
f8b57ff1bf zend_execute: Suppress values in UnhandledMatchError for zend.exception_ignore_args=1 (#17619)
Fixes php/php-src#17618.
2025-01-31 10:19:49 +01:00
Gina Peter Banyard
3ff7758bcf ext/pdo: Refactor PDO::FETCH_CLASS to not rely on a FCI and use a HashTable for ctor_arg
To call the constructor we now only store the CE and a HashTable for the arguments.
This reduces the size of the _pdo_stmt_t struct from 320 bytes to 232 bytes.
Moreover, this now means that the constructor argument array follows the usual CUFA semantics.
This change is a BC break, as string keys now act like named arguments.
Moreover, the automatic wrapping of by-value arguments for by-ref parameters has been dropped, and the usual E_WARNING is now emitted in those cases.

The do_fetch() is heavily refactored to simplify the execution flow, which also makes it easier to understand.
Additionally we add a new bitflag in_fetch to prevent modification of the fetch flags by userland when PDO is fetching from the DB.
2025-01-30 18:48:54 +00:00
Gina Peter Banyard
229df24ae8 Zend/GC: Add zend_get_gc_buffer_add_ht() function 2025-01-30 18:48:54 +00:00
Niels Dossche
b068c2ff94 Fix GH-17442: Engine UAF with reference assign and dtor
Closes GH-17443.
2025-01-30 19:43:03 +01:00
Gina Peter Banyard
09791ed1d1 ext/pdo: Convert database_object_handle zval to zend_object* (#17629)
This saves 8 bytes on the PDO statement struct.

We change the PGSQL PDO driver API to take a zend_object* instead of a zval* at the same time.
2025-01-30 18:34:03 +00:00
Niels Dossche
ef10339fe7 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in phpdbg calling registered function
  Partially fix GH-17387
2025-01-30 19:32:28 +01:00
Niels Dossche
29bafa6323 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in phpdbg calling registered function
  Partially fix GH-17387
2025-01-30 19:31:38 +01:00
ndossche
62bbfdebaa Fix memory leak in phpdbg calling registered function
Closes GH-17635.
2025-01-30 19:28:26 +01:00
ndossche
5447473785 Partially fix GH-17387
The length of the string should be set to the truncated length (that was
used to duplicate the input anyway).
2025-01-30 19:28:23 +01:00
Niels Dossche
6e84c41d05 Fix GH-12856: ReflectionClass::getStaticPropertyValue() returns UNDEF zval for uninitialized typed properties
Closes GH-17590.
2025-01-30 19:22:59 +01:00
Shivam Mathur
efca8cb682 ci: add workflow to trigger windows builds (#17634) 2025-01-30 23:14:59 +05:30
Calvin Buckley
5ad03fb0ce Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix potential read of uninitialized padding data in DOM (#17628)
2025-01-30 11:41:00 -04:00
Niels Dossche
81803b9b09 Fix potential read of uninitialized padding data in DOM (#17628)
The fix for GH-17481 introduced a regression that can cause the read of
uninitialized padding data when going over a chunk boundary during HTML
parsing of UTF-8.
The wrong offset was computed with respect to the input buffer, the
length of the error-corrected UTF-8 code point is not necessarily the
same as the input code point length.
This was not noticed because no CI jobs run with Valgrind nor I do it
regularly, and ASAN doesn't catch uninitialized accesses.
2025-01-30 11:26:58 -04:00
David Carlier
2ea386a516 ext/sockets: linux AF_PACKET support.
close GH-17440
2025-01-30 12:43:35 +00:00
Arnaud Le Blanc
9df1c930bf GDB script improvements (#17227)
* Support IS_INDIRECT, IS_PTR, IS_ALIAS_PTR when printing zvals
* Pretty print the ce_flags field when pretty printing a zend_class_entry
* Pretty print the const flags when pretty printing a zend_class_constant
* Added a minimal zend_property_info pretty printer to pretty print the flags field
* Added minimal zend_function, zend_op_array, and zend_internal_function pretty printers: The string value is the function/method name, function type (user/internal), and location (when possible). The fn_flags field is pretty printed
* Added a minimal zend_op pretty printer to pretty print the opcode
* Added a zend_refcounted_h pretty printer to pretty print the type_info
* Added minimal pretty printers for zend_object and zend_array
* Print the type and address of pretty-printed structs
* Added gdb commands: print_fn_flags, print_ce_flags, print_prop_flags, print_const_flags, print_ref_type_info, print_opcode, dump_op_array
* Fields of type zend_string, zend_class_entry, zend_array are printed by default in all our pretty printers, using short representation
* Increased the maximum length of printed strings to 200 chars before truncation (was 50)
2025-01-30 12:22:07 +01:00
Ilija Tovilo
fa7c67d622 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix stack overflow detection for variable compilation
2025-01-29 23:28:22 +01:00
Ilija Tovilo
4f91af38cc Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix stack overflow detection for variable compilation
2025-01-29 23:28:16 +01:00
Ilija Tovilo
333f5dd848 Fix stack overflow detection for variable compilation
Closes GH-17623
2025-01-29 23:27:27 +01:00
Gina Peter Banyard
0537968f00 ext/pdo: Use zend_object_alloc() for allocating PDORows (#17621)
Follow-up for GH-17606
2025-01-29 19:33:19 +00:00
Gina Peter Banyard
8d95b3da89 ext/pdo: Remove refcount field from _pdo_stmt_t (#17622)
It is unused, and removing it saves 8 bytes on 64 bits systems.
2025-01-29 19:33:06 +00:00
Christoph M. Becker
e1f3249285 Fix snmp_session_error.phpt for 32bit machines (GH-17611)
For `$retries === PHP_INT_MAX` there is no exception on 32bit machines.
To avoid splitting the tests, or even not running it on 32bit, we work
around.
2025-01-29 14:41:15 +01:00
Gina Peter Banyard
b667939b57 ext/pdo: Fix zend_object std layout for _pdo_row_t (#17606)
As of PHP 7 [1] the `std` should be at the end of the struct instead of at the beginning.

See GH-17598 for more UB related details.

[1] https://www.npopov.com/2015/06/19/Internal-value-representation-in-PHP-7-part-2.html#objects-in-php-7
2025-01-29 12:50:01 +00:00
Eric Norris
0a14ab18d2 RFC: Error Backtraces v2 (#17056)
see https://wiki.php.net/rfc/error_backtraces_v2

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-01-29 12:54:23 +01:00
Saki Takamachi
5bf6e2e378 Merge branch 'PHP-8.4'
* PHP-8.4:
  follow up for #17615
2025-01-29 19:25:05 +09:00
Saki Takamachi
18d96671a5 follow up for #17615
The deleted line has returned, so delete it again.
2025-01-29 19:25:03 +09:00
Saki Takamachi
c9fa625e41 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed GH-17398: bcmul memory leak (#17615)
2025-01-29 19:15:23 +09:00
Saki Takamachi
4c90bb2da4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fixed GH-17398: bcmul memory leak (#17615)
2025-01-29 19:15:10 +09:00
Saki Takamachi
5a4832f97b Fixed GH-17398: bcmul memory leak (#17615)
Changed BCG memory allocation to be forcibly released in
PHP_GSHUTDOWN_FUNCTION regardless of refcount.

Fixes #17398
Closes #17615
2025-01-29 19:12:18 +09:00
Remi Collet
b0abb49402 Merge branch 'PHP-8.4'
* PHP-8.4:
  relax test for zlib-ng
2025-01-29 11:04:30 +01:00
Remi Collet
6945e60f54 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  relax test for zlib-ng
2025-01-29 11:04:20 +01:00
Remi Collet
ed1d51fa4f relax test for zlib-ng 2025-01-29 11:03:59 +01:00
Niels Dossche
6f4579af85 Introduce php_pdo_stmt_valid_db_obj_handle() (#17567) 2025-01-28 21:54:11 +01:00
Jakub Zelenka
ad6cdb5aaa Merge branch 'PHP-8.4' 2025-01-28 19:47:10 +01:00
Jakub Zelenka
cf5d227597 Merge branch 'PHP-8.3' into PHP-8.4 2025-01-28 19:46:47 +01:00
Jakub Zelenka
c4b678fa70 PHP-8.3 is now for PHP 8.3.18-dev 2025-01-28 19:45:52 +01:00
Tim Düsterhus
9241ca42bc zend_object_handlers: Use zend_array_release() in zend_release_properties() and zend_free_trampoline() (#17608) 2025-01-28 19:34:41 +01:00