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

14859 Commits

Author SHA1 Message Date
Jakub Zelenka
789132c74f Fix incorrectly ported tests for http 2025-03-05 19:01:14 +01:00
Jakub Zelenka
963551715a Fix GHSA-hgf5-96fm-v528: http user header check of crlf 2025-03-05 13:42:52 +01:00
Jakub Zelenka
2488e73d1f Fix GHSA-52jp-hrpf-2jff: http redirect location truncation
It converts the allocation of location to be on heap instead of stack
and errors if the location length is greater than 8086 bytes.
2025-03-05 13:42:11 +01:00
Jakub Zelenka
61bb8ef240 Fix GHSA-pcmh-g36c-qc44: http headers without colon
The header line must contain colon otherwise it is invalid and it needs
to fail.

Reviewed-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-03-05 13:41:22 +01:00
Jakub Zelenka
9fe496696d Fix GHSA-ghsa-v8xr-gpvj-cx9g: http header folding
This adds HTTP header folding support for HTTP wrapper response
headers.

Reviewed-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-03-05 12:43:37 +01:00
Jakub Zelenka
ed00c1d74b Merge branch 'PHP-8.3' into PHP-8.4 2025-02-24 23:22:47 +01:00
Jakub Zelenka
930624899b Fix bug #72666: stat cache not cleared for plain paths
This adds more aggressive clearing of stat cache. It is added to the
filestat as well as plain wrapper operations which covers stream file
accessing as well as exec functions (using pipes). It should hopefully
fix the most visible issues with the stat cache.

Closes GH-17681
2025-02-24 23:21:45 +01:00
Christoph M. Becker
2c911e400a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17879: readfile_variation8-win32.phpt test conflict
2025-02-22 00:10:51 +01:00
Christoph M. Becker
769f292a7a Fix GH-17879: readfile_variation8-win32.phpt test conflict
Apparently a copy and paste issue.

Closes GH-17881.
2025-02-22 00:09:53 +01:00
Christoph M. Becker
8a6370d7a9 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Adapt tests to Windows 11
2025-02-17 00:08:43 +01:00
Christoph M. Becker
765cebf73a Adapt tests to Windows 11
Apparently, one of the more recent patch releases of Windows 10
(confirmed for Windows 10.0.26100, but may affect older versions, too)
changed treatment of filenames with trailing slashes to be recognized
explicitly as directories, and no longer as invalid file or directory.

We adapt the affected test cases.

Closes GH-17804.
2025-02-17 00:07:55 +01:00
Niels Dossche
c2e5c58736 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17650: realloc with size 0 in user_filters.c
2025-02-07 20:24:00 +01:00
Niels Dossche
fd5d6ad5bd Fix GH-17650: realloc with size 0 in user_filters.c
If the returned buffer string is of length 0, then a realloc can happen
with length 0. However, the behaviour is implementation-defined.
From 7.20.3.1 of C11 spec:

> If the size of the space requested is zero, the behavior is
> implementation-defined: either a null pointer is returned,
> or the behavior is as if the size were some nonzero value,
> except that the returned pointer shall not be used to access an object

This is problematic for the test case on my system as it returns NULL,
causing a memleak and later using it in memcpy causing UB.
The bucket code is not prepared to handle a NULL pointer.
To solve this, we use MAX to clamp the size to 1 at the least.

Closes GH-17656.
2025-02-07 20:22:52 +01:00
Ilija Tovilo
4ac2c3653b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add CONFLICT all to random port test
2025-02-06 15:26:02 +01:00
Ilija Tovilo
68d2bc42fc Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add CONFLICT all to random port test
2025-02-06 15:25:47 +01:00
Ilija Tovilo
c5045a04f2 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Add CONFLICT all to random port test
2025-02-06 15:25:41 +01:00
Ilija Tovilo
726cf51236 Add CONFLICT all to random port test
If we're very unlucky, we can get the same port opened as an ephemeral
port by some other test.

Closes GH-17706
2025-02-06 15:25:16 +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
ae3ab37816 Fix GH-17447: Assertion failure when array popping a self addressing variable
This is the same bug as GH-16957, and fixed in the same way.

Closes GH-17448.
2025-01-16 20:28:51 +01:00
Jakub Zelenka
35c03c165e Merge branch 'PHP-8.3' into PHP-8.4 2025-01-06 12:20:50 +01:00
Jakub Zelenka
5b72f12c56 Rewrite http gh16810 test to not be online
Closes GH-17314
2025-01-06 12:20:13 +01:00
Jakub Zelenka
3606701f48 Merge branch 'PHP-8.2' into PHP-8.3 2025-01-06 12:19:36 +01:00
Jakub Zelenka
5be673d29e Merge branch 'PHP-8.1' into PHP-8.2 2025-01-06 12:18:54 +01:00
Jakub Zelenka
9e1b58274e Test stream_context_tcp_nodelay_server on Windows
Closes GH-17308
2025-01-05 14:44:22 +01:00
Christoph M. Becker
862ed7ebe5 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  gh15937.phpt does not need to be an online test
2025-01-01 20:08:04 +01:00
Christoph M. Becker
9999a5b4de Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  gh15937.phpt does not need to be an online test
2025-01-01 20:07:34 +01:00
Christoph M. Becker
919f1984d5 gh15937.phpt does not need to be an online test
We convert the test to use the CLI test server to not require online
availability.

As of PHP 8.3, the test is supposed to fail, because the timeout is too
large.  Since exactly this scenario is already tested by gh16810.phpt,
we drop the test for PHP-8.3 and up.

Closes GH-17315.
2025-01-01 20:06:23 +01:00
Jakub Zelenka
d2977b026f Merge branch 'PHP-8.3' into PHP-8.4 2024-12-31 15:20:06 +01:00
Jakub Zelenka
19e2e4d5af Port stream bug51056 and gh11418 tests to use ephemeral ports 2024-12-31 15:18:50 +01:00
Jakub Zelenka
e0dabe326f Merge branch 'PHP-8.2' into PHP-8.3 2024-12-31 15:05:18 +01:00
Jakub Zelenka
44a9154e75 Merge branch 'PHP-8.1' into PHP-8.2 2024-12-31 14:39:59 +01:00
Jakub Zelenka
b8731767d8 Fix GH-16955: Use empheral ports for OpenSSL server client tests
And refactor some client server tests.

Closes GH-17180
2024-12-31 14:25:19 +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
Christoph M. Becker
a8ffabfc91 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17067: glob:// wrapper doesn't cater to CWD for ZTS builds
2024-12-18 13:04:10 +01:00
Christoph M. Becker
53b69ba8cf Fix GH-17067: glob:// wrapper doesn't cater to CWD for ZTS builds
`glob(3)` doesn't know the virtual CWD of PHP, so we need to pass an
absolute path for ZTS builds.  In lack of a reusable routine, we copy
the code from `glob()` and adapt as needed.

Closes GH-17074.
2024-12-18 13:02:48 +01:00
Christoph M. Becker
fd25b79412 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Don't run proc_open_cmd.phpt in parallel with other tests
2024-12-15 12:10:47 +01:00
Christoph M. Becker
aafa6ea386 Don't run proc_open_cmd.phpt in parallel with other tests
This test puts a fake cmd.exe in the CWD and removes it only after the
test has finished.  We need to avoid that other tests are running while
that fake cmd.exe is there, because they may use it instead of the
proper cmd.exe.

We also unlink the fake cmd.exe as soon as possible, regardless of the
test result.

Fixes GH-17098.
Closes GH-17090.
2024-12-15 12:09:42 +01:00
David Carlier
fc3ac345d7 Merge branch 'PHP-8.3' into PHP-8.4 2024-12-08 20:30:16 +00:00
David Carlier
301b8e24c1 Fix GH-16809: fopen HTTP wrapper timeout stream context option overflow.
close GH-16810
2024-12-08 20:29:57 +00:00
Christoph M. Becker
e8bb0a8ba0 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Harden proc_open() against cmd.exe hijacking
2024-12-08 19:10:12 +01:00
Christoph M. Becker
5cbdd5f6de Harden proc_open() against cmd.exe hijacking
As is, whenever `proc_open()` needs to invoke the shell, cmd.exe is
looked up in the usual executable search path.  That implies that any
cmd.exe which is placed in the current working directory (which is not
necessarily what is reported by `getcwd()` for ZTS builds), will be
used.  This is a known attack vector, and Microsoft recommends to
always use the fully qualified path to cmd.exe.

To prevent any cmd.exe in the current working directory to be used, but
to still allow users to use a drop in replacement for cmd.exe, we
search only the `PATH` for cmd.exe (and pass the fully qualified path
to `CreateProcessW`), instead of relying on automatic executable search
by passing the base name only.

To be able to easily test this, we provide a minimalist C file which
will be build as test_helper, and used by the new test case.

[1] <https://msrc.microsoft.com/blog/2014/04/ms14-019-fixing-a-binary-hijacking-via-cmd-or-bat-file/>

Closes GH-17043.
2024-12-08 19:08:02 +01:00
Christoph M. Becker
141ee868c0 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Skip parse_ini_file_variation6.phpt on Windows
2024-12-06 23:53:47 +01:00
Christoph M. Becker
3167c7b1f2 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Skip parse_ini_file_variation6.phpt on Windows
2024-12-06 23:52:47 +01:00
Christoph M. Becker
b3b38e2d5c Skip parse_ini_file_variation6.phpt on Windows
While the test obviously succeeds on Windows, it may occasionally
conflict with parse_ini_file_variation6-win32.phpt[1], so we skip it
like we do for many other of these tests which have win32 pendants.

[1] <https://github.com/php/php-src/actions/runs/12077554275/job/33680647284#step:6:119>

Closes GH-16989.
2024-12-06 23:52:03 +01:00
Niels Dossche
d6d78545ea Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17037: UAF in user filter when adding existing filter name due to incorrect error handling
2024-12-04 20:05:32 +01:00
Niels Dossche
00f4881e90 Fix GH-17037: UAF in user filter when adding existing filter name due to incorrect error handling
There are two functions that can each fail in their own way. If the last
function fails we have to remove the filter entry from the hash table,
otherwise we risk a UAF. Note also that removing the entry from the
table on failure will also free its memory.

Closes GH-17038.
2024-12-04 20:04:53 +01:00
divinity76
c2d3734e89 Fix GH-15964: printf() can strip sign of -INF
We need to cater to negative infinity explicitly.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-15965.
2024-12-02 14:27:36 +01:00