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

140313 Commits

Author SHA1 Message Date
Niels Dossche
9040e795ed Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix fallback paths in fast_long_{add,sub}_function
2025-02-03 22:43:24 +01:00
Niels Dossche
c7d3c5fcb1 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix fallback paths in fast_long_{add,sub}_function
2025-02-03 22:40:41 +01:00
Niels Dossche
7e06a81bbd Fix fallback paths in fast_long_{add,sub}_function
This was asked to be checked in https://github.com/php/php-src/pull/17472#issuecomment-2591325036

There are 2 issues:
1) The UB in the if can overflow, and can be fixed by using zend_ulong
   for the sum/sub.
2) fast_long_sub_function() has a problem when result aliases.
   This is fixed in the same way as fast_long_add_function() works.

Closes GH-17666.
2025-02-03 22:38:00 +01:00
Christoph M. Becker
c1f7b87fb1 Fix MSVC C4267 warnings in gd.c (GH-17680)
These warnings are about conversion from `size_t` to a smaller type[1],
and in this case because `gdIOCtx` works with `int` lengths.  Two of
these warnings are harmless, and we resolve them by using `size_t` in
the first place, and adding a cast (plus an assertion), respectively.

The others actually hint at potential issues when reading image data
with more than `INT_MAX` bytes; we catch that upfront, and throw a
`ValueError` and a warning, respectively.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267>
2025-02-03 21:02:15 +01:00
Christoph M. Becker
4373c601ea Remove more unused local variables (GH-17688)
Since `pdo_odbc_ucs22utf8()` doesn't actually use the `stmt`, we drop
this parameter as well.
2025-02-03 20:06:29 +01:00
Niels Dossche
1879ec1713 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17577: JIT packed type guard crash
2025-02-03 19:38:04 +01:00
Niels Dossche
78da288222 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17577: JIT packed type guard crash
2025-02-03 19:35:32 +01:00
Niels Dossche
0c3cf1f311 Fix GH-17577: JIT packed type guard crash
When a guard check is created for a variable to check if it's a packed array,
it is possible that there was no prior type check for that variable.
This happens in the global scope for example when the variable aliases.
In the test, this causes a dereference of address 8 because the integer
element in `$a` is interpreted as an array address.

This patch adds a check to see if the guard is handled.
If we were not able to determine or guard the type then we also cannot know the array is packed.

Closes GH-17584.
2025-02-03 19:34:39 +01:00
Niels Dossche
9b7e08603b Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17654: Multiple classes using same trait causes function JIT crash
2025-02-03 19:28:26 +01:00
Niels Dossche
6d6380c09d Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17654: Multiple classes using same trait causes function JIT crash
2025-02-03 19:28:20 +01:00
Niels Dossche
f88445bdf8 Fix GH-17654: Multiple classes using same trait causes function JIT crash
This test has two classes that use the same trait. In function JIT mode
the same cache slot will be used. This causes problems because it is
primed for the first class and then reused for the second class,
resulting in an incorrect type check failure.

The current check for a megamorphic trait call requires current_frame to
not be NULL, but this is only set in tracing mode and not in function
mode.

This patch corrects the check.

Closes GH-17660.
2025-02-03 19:21:15 +01:00
Christoph M. Becker
4e6a3cecf5 Don't forward declare static functions in sendmail.h (GH-17684)
sendmail.h is not only included by sendmail.c, but also by
php_win32_globals.h, because that header uses some of the defined
macros.  However, the forward declarations of the static functions are
not needed anywhere else than in sendmail.c, and Clang warns about the
unused functions elsewhere (`-Wunused-function`).  Thus we move the
forward declarations to sendmail.c.
2025-02-03 16:50:32 +01:00
Christoph M. Becker
3fa9e283a0 Drop unused local variables (GH-17682) 2025-02-03 16:42:29 +01:00
Christoph M. Becker
caf5e8a167 Solve C4267 warnings in win32/ioutil for x64 (GH-17674)
C4267[1] are about conversion from `size_t` to a "smaller" type,
causing potential loss of data (aka. truncation).

In this case we can solve that cleanly (i.e. without casting and
further checks) by changing the affected variables to be of type
`DWORD`.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267>
2025-02-03 00:13:58 +01:00
Gina Peter Banyard
6ae12093ce ext/pdo: Rearrange struct to pack and group related fields together (#17651)
All bound related fields are now part of the same cache line
2025-02-02 21:25:29 +00:00
Niels Dossche
ff80ec70c6 Add enchant_dict_remove() (#17507) 2025-02-02 19:14:49 +01:00
Niels Dossche
50ed7b58bf Add non-NULL assertion to zend_get_gc_buffer_add_obj() (#17671)
This would've saved me time when fixing the nightly failure in Laravel [1].

[1] e306a2e0
2025-02-02 19:09:53 +01:00
Christoph M. Becker
5f7a9ee97e Merge branch 'PHP-8.4'
* PHP-8.4:
  Relax timezone_IDforWindowsID_basic2.phpt expectations
2025-02-02 13:39:13 +01:00
Christoph M. Becker
59ed63732f Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Relax timezone_IDforWindowsID_basic2.phpt expectations
2025-02-02 13:38:36 +01:00
Christoph M. Becker
76fccc2b02 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Relax timezone_IDforWindowsID_basic2.phpt expectations
2025-02-02 13:37:21 +01:00
Christoph M. Becker
036f00f146 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Relax timezone_IDforWindowsID_basic2.phpt expectations
2025-02-02 13:36:39 +01:00
Christoph M. Becker
afe8e2cdff Relax timezone_IDforWindowsID_basic2.phpt expectations
Apparently, some ICU versions report "America/Los_Angeles" for the `ZZ`
case, what matches the behavior of ICU 76.1 (on Windows).  Possibly,
there has been some bug fix backport on some systems.  Anyhow, either
seems fine, so we're not picky about that.

Closes GH-17669.
2025-02-02 13:35:27 +01:00
Shivam Mathur
0d8aebf1d9 Fix condition to check for config.w32 in phpize (#17667) 2025-02-02 08:49:16 +05:30
Niels Dossche
e306a2e0e8 Add missing NULL checks in dbstmt_get_gc
This fixes the nightly Laravel failure: https://github.com/php/php-src/actions/runs/13083746886/job/36512023794
2025-02-01 23:58:44 +01:00
Christoph M. Becker
f1702d2bb1 Suppress MSVC C4995 warnings (deprecations)
These have the same meaning as C4996[1] (which we already suppress),
but are triggered by a different mechanism[2].  It makes no sense to
suppress one, but not both.

Of course it would be better not to suppress either, but wrt the two
C4995 warnings we see in php-src, that requires deprecation of using
the ODBC cursor library[3], so might take a while.

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

Closes GH-17664.
2025-02-01 22:48:43 +01:00
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