1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 18:22:42 +01:00
Commit Graph

14540 Commits

Author SHA1 Message Date
haszi
701f3a1af6 Mark ob_start callback parameter nullable 2025-04-14 22:35:06 +02:00
Niels Dossche
8a1f6711bf Fix resource leak in iptcembed() on error
Closes GH-18225.
2025-04-02 21:05:48 +02:00
David Carlier
2e47442a6b Fix GH-18212: fseek with SEEK_CUR and negative offset crash on debug
Triggers the assertion as with SEEK_CUR the stream position is set to a
negative value so we force the failure without affecting its position
instead.

close GH-18224
2025-04-02 12:34:50 +01:00
Ilija Tovilo
a21065e6eb Use-after-free in extract() with EXTR_REFS
Fixes GH-18209
Closes GH-18211
2025-04-01 16:33:30 +02:00
Jakub Zelenka
2197a490f7 Fix GH-18145: basic_globals_ctor initialization
This resets all basic globals during ctor and just modifies the ones
with a special value. It also switches to using basic_globals_p which
what should be used in this context.

Closes GH-18156
2025-03-27 11:35:55 +01:00
Jakub Zelenka
bd7d3c38ad Get rid of atime change testing in bug72666_variation3.phpt 2025-03-17 14:49:22 +01:00
Jakub Zelenka
acf2f4988a Merge branch 'PHP-8.2' into PHP-8.3 2025-03-11 22:09:00 +01:00
Jakub Zelenka
4af1830356 Merge branch 'PHP-8.1' into PHP-8.2 2025-03-11 21:57:33 +01:00
Jakub Zelenka
41d49abbd9 Fix GHSA-hgf5-96fm-v528: http user header check of crlf 2025-03-11 21:50:16 +01:00
Jakub Zelenka
ac1a054bb3 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-11 21:50:16 +01:00
Jakub Zelenka
0548c4c175 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-11 21:50:16 +01:00
Jakub Zelenka
d20b4c97a9 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-11 21:50:16 +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
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
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
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
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
ed1d51fa4f relax test for zlib-ng 2025-01-29 11:03:59 +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
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
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
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
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
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
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
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
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
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
Niels Dossche
f1fc4e8ff7 Fix GH-16957: Assertion failure in array_shift with self-referencing array
We have an RC1 violation because we're immediately dereferencing and
copying the resulting array in the test case. Instead, transfer the
lifetime using RETVAL_COPY_VALUE and unwrap only after the internal
iterator is reset.

Closes GH-16970.
2024-11-29 19:21:11 +01:00
Niels Dossche
6a195bd9e7 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16905: Internal iterator functions can't handle UNDEF properties
2024-11-28 19:22:36 +01:00
Niels Dossche
e1b4534790 Fix GH-16905: Internal iterator functions can't handle UNDEF properties
Closes GH-16907.
2024-11-28 19:22:10 +01:00
Christoph M. Becker
0b5de3014a Use another for bug51056.phpt
This port is already used by san_ipv6_peer_matching.phpt, wo we choose
another port which is not explicitly used in our test suite.  The
proper solution would be to use ephemeral ports[1], but our OpenSSL
`ServerClientTestCase` does not support this yet.

[1] <6ab4e330ac>

Closes GH-16871.
2024-11-25 22:06:04 +01:00
Christoph M. Becker
4ceae71954 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix potential conflict of copy_variation5-win32.phpt
2024-11-25 13:49:20 +01:00
Christoph M. Becker
12ef3da381 Fix potential conflict of copy_variation5-win32.phpt
copy_variation1.phpt also creates and deletes a file copy.tmp in the
same folder, so conflicts may occur[1].  We apply a quick fix.

[1] <https://github.com/php/php-src/actions/runs/11902293714/job/33167012826>

Closes GH-16854.
2024-11-25 13:48:50 +01:00
Christoph M. Becker
38ec780015 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Skip file_put_contents_variation7.phpt on Windows
2024-11-20 15:50:54 +01:00
Christoph M. Becker
3656a84c39 Skip file_put_contents_variation7.phpt on Windows
While the test obviously succeeds on Windows, it may occasionally
conflict with file_put_contents_variation7-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/11527743659/job/32093951818>

Closes GH-16722.
2024-11-20 15:50:24 +01:00
Jakub Zelenka
ffff27f734 Merge branch 'PHP-8.2' into PHP-8.3 2024-11-20 11:12:19 +01:00
Niels Dossche
f3ade203d7 Fix GHSA-r977-prxv-hc43
Move the bound check upwards. Since this doesn't generate output we can
check the bound first.
2024-11-20 11:07:04 +01:00
Jakub Zelenka
d7fe40868e Fix GHSA-c5f2-jwm7-mmq2: stream HTTP fulluri CRLF injection 2024-11-20 11:06:02 +01:00