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

135275 Commits

Author SHA1 Message Date
David Carlier
3bea6a2ddb ext/sockets: socket_strerror follow-up on GH-16267 fix.
boundaries should be INT_MIN <= val < INT_MAX in fact.

close GH-16891
2024-12-09 13:16:32 +00:00
Christoph M. Becker
3702f9783b opcache_get_configuration() properly reports jit_prof_threshold
The `jit_prof_threshold` is a float, supposed to be in range [0, 1],
and usually very small (the default is 0.005).  Reporting it as int
is meaningless.

Closes GH-17077.
2024-12-09 11:45:16 +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
1800cad9d9 Properly check for required icu4c libraries
Besides that just checking for icuuc.lib does not necessarily imply
that the other libraries are available, doing it this way will not copy
the PDBs to the build folder, so these are not available in the debug
packages.  Furthermore, `CHECK_LIB` already adds the library to the
flags, so there is no need to do this manually.

Closes GH-17010.
2024-12-07 15:10:06 +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
7acc3ac808 Fix GH-17040: SimpleXML's unset can break DOM objects
Don't free the underlying nodes if we still have objects pointing to
them, otherwise the objects are left with a NULL node pointer.

Closes GH-17046.
2024-12-06 20:06:51 +01:00
Michael Orlitzky
def271aaa7 ext/dba/tests/gh16390.phpt: skip if inifile is disabled
This test reads an ini "file" from a string, and expects a warning
about locking. But if inifile support is disabled, then you'll get

  Warning: dba_open(): Handler "inifile" is not available in
  /path/to/ext/dba/tests/gh16390.php on line 3

instead. We skip the test if inifile support is disabled.

Closes GH-17011.
2024-12-06 19:01:50 +01:00
Niels Dossche
ddbd396aa2 Fix GH-17047: UAF on iconv filter failure
The first while loop sets the bucket variable, and this is freed in
out_failure. However, when the second "goto out_failure" is triggered
then bucket still refers to the bucket from the first while loop,
causing a UAF.
Fix this by separating the error paths.

Closes GH-17058.
2024-12-06 17:43:38 +01:00
Dmitry Stogov
6bac907cb1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Backport fix for GH-9011 (#17052)
2024-12-05 18:32:18 +03:00
Dmitry Stogov
9d4f5f0762 Backport fix for GH-9011 (#17052)
* Backport fix for GH-9011

* Fix build
2024-12-05 18:32:02 +03:00
Christoph M. Becker
e50cf7a7a0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Revert "Enable GHSA-9pqp-7h25-4f32.phpt on Windows"
2024-12-04 20:45:39 +01:00
Christoph M. Becker
e532d9afb5 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Revert "Enable GHSA-9pqp-7h25-4f32.phpt on Windows"
2024-12-04 20:44:47 +01:00
Christoph M. Becker
2285d7083e Revert "Enable GHSA-9pqp-7h25-4f32.phpt on Windows"
This reverts commit 7685fb0e1c.

The test fails at least for PHP-8.2+ on CI. Needs closer investigation.
2024-12-04 20:43:49 +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
Christoph M. Becker
9c40bdaaf5 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Enable GHSA-9pqp-7h25-4f32.phpt on Windows
2024-12-04 19:04:52 +01:00
Christoph M. Becker
c17b5bae8a Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Enable GHSA-9pqp-7h25-4f32.phpt on Windows
2024-12-04 19:04:22 +01:00
Christoph M. Becker
7685fb0e1c Enable GHSA-9pqp-7h25-4f32.phpt on Windows
Closes GH-16933.
2024-12-04 19:03:42 +01:00
Jakub Zelenka
b1e3dcf88a PHP-8.3 is now for PHP 8.3.16-dev 2024-12-03 18:45:43 +01:00
Sergey Panteleev
432078ec4d Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  PHP-8.2 is now for PHP 8.2.28-dev

# Conflicts:
#	Zend/zend.h
#	configure.ac
#	main/php_version.h
2024-12-03 16:48:39 +03:00
Sergey Panteleev
7fbeee0c2f PHP-8.2 is now for PHP 8.2.28-dev 2024-12-03 16:48:02 +03:00
Niels Dossche
51e0920e45 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix some MariaDB test failures
2024-12-02 19:21:03 +01:00
Niels Dossche
1a6f8a0b79 Fix some MariaDB test failures
Allow other wording too such that these mysqli tests pass.

Closes GH-17004.
2024-12-02 19:20:54 +01:00
David Carlier
60eca67439 Merge branch 'PHP-8.2' into PHP-8.3 2024-12-01 13:58:21 +00:00
David Carlier
73ebc92617 Fix GH-16959: snmpget modifies the object_id (as array).
Instead of modifying the zval, we use the zend_try_get_string.

close GH-16969
2024-12-01 13:57:31 +00:00
Niels Dossche
4eaa6f9d4e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16998: UBSAN warning in rfc1867
2024-12-01 10:59:59 +01:00
Niels Dossche
aab784263d Fix GH-16998: UBSAN warning in rfc1867
The "else branch" of `next_line` can reset the `buf_begin` field to
NULL, causing the next invocation to pass NULL to `memchr` with a 0
length. When UBSAN is enabled this causes an UBSAN abort. Real world
impact is likely none because of the 0 length.

To fix this, don't set the pointer to NULL, which means that the
`memchr` will return NULL and since
`self->bytes_in_buffer < self->bufsize` we return NULL and request more
data through `fill_buffer`. That function will reset `buf_begin` and
`bytes_in_buffer` so that the next invocation works fine.

I chose this solution so we have an invariant that `buf_begin` is never
NULL, which makes reasoning easier. An alternative solution is keeping
the NULLing of `buf_begin` and add an extra check at the top of
`next_line`, but I didn't like special casing this.

Closes GH-17000.
2024-12-01 10:59:30 +01:00
Christoph M. Becker
65070bb46c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix potential OOB read in zend_dirname() on Windows
2024-11-29 22:09:40 +01:00
Christoph M. Becker
94fa2a4ce1 Fix potential OOB read in zend_dirname() on Windows
Only on Windows `IS_SLASH_P()` may read the previous byte, and so may
in unlikely cases read one byte out of bounds.  Since `IS_SLASH_P()` is
in a public header (albeit not likely to be used by external extensions
or SAPIs), we introduce `IS_SLASH_P_EX()` which accepts a second
argument to prevent that OOB read.

It should be noted that the PHP userland function `dirname()` is not
affected by this issue, since it does not call `zend_dirname()` on
Windows.

Closes GH-16995.
2024-11-29 22:08:06 +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
Christoph M. Becker
a4874bb418 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16991: Getting typeinfo of non DISPATCH variant segfaults
2024-11-29 16:30:01 +01:00
Christoph M. Becker
9bae8933a3 Fix GH-16991: Getting typeinfo of non DISPATCH variant segfaults
We must not assume that any `VARIANT` implements `IDispatch`.

Closes GH-16992.
2024-11-29 16:29:11 +01:00
Jakub Zelenka
6f05d96a2b Merge branch 'PHP-8.2' into PHP-8.3 2024-11-29 07:56:28 +01:00
Jakub Zelenka
69765d9220 Fix network connect poll interuption handling
When connecting to socket, it is possible to get EINTR. In such case,
there should be an another attempt to connect if we are not over the
timeout. The timeout should be adjusted accordingly in that case.

This fixes https://github.com/phpredis/phpredis/issues/1881

Closes GH-16606
2024-11-29 07:54:06 +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
David Carlier
841e54daee Merge branch 'PHP-8.2' into PHP-8.3 2024-11-27 19:54:06 +00:00
David Carlier
5fd53a8b93 [skip ci] NEWS 2024-11-27 19:53:09 +00:00
David Carlier
7e8d6f941c Revert "ext/gmp: gmp_pow fix FPE with large values."
This reverts commit d70b7811b0.
2024-11-27 19:52:07 +00:00
David Carlier
45140e527f Revert "ext/gmp: gmp_pow fix FPE with large values."
This reverts commit e0a0e216a9.
2024-11-27 19:52:04 +00:00
Niels Dossche
3c3ec0e61a Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15208: Segfault with breakpoint map and phpdbg_clear()
2024-11-26 22:27:06 +01:00
Niels Dossche
97b03186c4 Fix GH-15208: Segfault with breakpoint map and phpdbg_clear()
It crashes because it's gonna try accessing the breakpoint which was cleared
by user code in `phpdbg_clear();`. Not all breakpoint data was properly
cleaned.

Closes GH-16953.
2024-11-26 22:26:37 +01:00
Niels Dossche
21df4a97a3 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Backport GH-14962 to stable versions
2024-11-26 21:25:05 +01:00
Michael Orlitzky
ae84b81bfa Backport GH-14962 to stable versions
Alpine CI regularly fails because of the sorting order of these tests.
See https://github.com/php/php-src/pull/14962#issuecomment-2498799881

Closes GH-16950.
2024-11-26 21:24:48 +01:00
Niels Dossche
89060216a3 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix various memory leaks in curl mime handling
2024-11-26 20:37:51 +01:00
Niels Dossche
a80f0b515a Fix various memory leaks in curl mime handling
Closes GH-16745.
2024-11-26 20:37:22 +01:00
Niels Dossche
02b1056714 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix is_zend_ptr() huge block comparison
2024-11-26 19:24:31 +01:00
Niels Dossche
18674e39ad Fix is_zend_ptr() huge block comparison
We should compare the block memory, not the block metadata (See
zend_mm_add_huge_block).
This caused random test failure for ext/ffi/tests/gh14626.phpt when the
malloc() performed by the FFI code lies close to the block metadata, and
the size of the block is large enough.

This was reported by https://github.com/php/php-src/issues/16902#issuecomment-2498310452

Closes GH-16938.
2024-11-26 19:24:05 +01:00
Derick Rethans
e43a398149 Merge branch 'PHP-8.2' into PHP-8.3 2024-11-26 15:40:56 +00:00