Commit graph

135748 commits

Author SHA1 Message Date
Niels Dossche
4aac98f145
Fix OSS-Fuzz #428983568 and #428760800
Both these issues have the same root cause, their reproducer is
extremely similar so I don't duplicate the test.

If the parser invokes the lexer, and the lexer fails, it could've
allocated a string which must be freed when the parser backs up.
The `%destructor` list is responsible for this but did not have an entry
for `fallback` yet. Solve the issue by adding such an entry.

Closes GH-19012.
2025-07-04 23:58:06 +02:00
Ben Ramsey
304d223a2f
Merge branch 'PHP-8.2' into PHP-8.3 2025-07-03 10:35:31 -05:00
Ben Ramsey
58977be208
Merge branch 'PHP-8.1' into PHP-8.2 2025-07-03 10:35:05 -05:00
Ilija Tovilo
b6660634b4
Disable JIT on Apple Silicon + ZTS
Apple Silicon has stricter rules about rwx mmap regions. They need to be created
using the MAP_JIT flag. However, the MAP_JIT seems to be incompatible with
MAP_SHARED. ZTS requires MAP_SHARED so that some threads may execute code from a
page while another writes/appends to it. We did not find another solution, other
than completely disabling JIT for Apple Silicon + ZTS.

See discussion in https://github.com/php/php-src/pull/13351.

Co-authored-by: Peter Kokot <peterkokot@gmail.com>
Fixes GH-13400
Closes GH-13396
2025-07-03 10:34:04 -05:00
SakiTakamachi
c161bb0c18
Fix GH-18873 - Free column->descid appropriately (#18957)
fixes #18873
closes #18957
2025-07-03 21:09:44 +09:00
Niels Dossche
69328ba304
Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction
Currently the resource is attached to the object and its refcount is
increased. This means that the refcount to the resource is 2 instead of
1 as expected. A refcount of 2 is necessary in the current code because
of how the error handling works: by using convert_to_null() the resource
actually goes to rc_dtor_func(), dropping its refcount to 1. So on error
the refcount is correct.
To solve the issue, let `stream` conceptually be a borrow of the
resource with refcount 1, and just use ZVAL_NULL() to prevent calling
rc_dtor_func() on the resource.

Closes GH-19001.
2025-07-02 18:44:05 +02:00
Niels Dossche
09c223de00
Fix leak when path is too long in ZipArchive::extractTo()
I did not find an easy way to trigger this branch without also
triggering some other error conditions earlier.

Closes GH-19002.
2025-07-02 18:43:25 +02:00
Niels Dossche
11ea995ff3
curl: Remove incorrect string release on error
The string is owned by the caller, and the caller releases it.

Closes GH-18989.
2025-07-02 18:42:50 +02:00
Ben Ramsey
fa960f7d95
Merge branch 'PHP-8.2' into PHP-8.3 2025-07-01 15:21:38 -05:00
Ben Ramsey
442638e562
Merge branch 'PHP-8.1' into PHP-8.2 2025-07-01 15:21:23 -05:00
Ben Ramsey
ca09f4dba4
PHP-8.1 is now for PHP 8.1.34-dev 2025-07-01 15:17:40 -05:00
Ben Ramsey
13bc0e2367
Merge branch 'PHP-8.1.33-security' into PHP-8.1 2025-07-01 15:13:25 -05:00
Sergey Panteleev
b576ad4ca3
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  PHP-8.2 is now for PHP 8.2.30-dev
  Update NEWS with entries for security fixes
  Fix GHSA-453j-q27h-5p8x
  Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
  Fix GHSA-3cr5-j632-f35r: Null byte in hostnames

# Conflicts:
#	Zend/zend.h
#	configure.ac
#	ext/pgsql/pgsql.c
#	main/php_version.h
2025-07-01 19:58:02 +03:00
Niels Dossche
91749844e6
Fix OSS-Fuzz #427814456
The first warning may trigger an error handler, destroying the operand
and its string. So we need to protect the string in that case.
Care was taken to avoid unnecessary refcounts and to avoid touching the
hot code path.

Closes GH-18951.
2025-07-01 18:50:41 +02:00
Sergey Panteleev
3d8cc222d5
PHP-8.2 is now for PHP 8.2.30-dev 2025-07-01 19:49:50 +03:00
Jakub Zelenka
165e5169a9
Update NEWS with entries for security fixes 2025-07-01 19:46:54 +03:00
Ahmed Lekssays
0298837252
Fix GHSA-453j-q27h-5p8x
Libxml versions prior to 2.13 cannot correctly handle a call to
xmlNodeSetName() with a name longer than 2G. It will leave the node
object in an invalid state with a NULL name. This later causes a NULL
pointer dereference when using the name during message serialization.

To solve this, implement a workaround that resets the name to the
sentinel name if this situation arises.

Versions of libxml of 2.13 and higher are not affected.

This can be exploited if a SoapVar is created with a fully qualified
name that is longer than 2G. This would be possible if some application
code uses a namespace prefix from an untrusted source like from a remote
SOAP service.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-07-01 19:46:51 +03:00
Jakub Zelenka
a2cdff5583
Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-07-01 19:46:48 +03:00
Jakub Zelenka
27e67cc371
Fix GHSA-3cr5-j632-f35r: Null byte in hostnames
This fixes stream_socket_client() and fsockopen().

Specifically it adds a check to parse_ip_address_ex and it also makes
sure that the \0 is not ignored in fsockopen() hostname formatting.
2025-07-01 19:46:42 +03:00
Jakub Zelenka
fc49d33449
Update NEWS with entries for security fixes 2025-07-01 09:37:50 -07:00
Ahmed Lekssays
dd060656d3
Fix GHSA-453j-q27h-5p8x
Libxml versions prior to 2.13 cannot correctly handle a call to
xmlNodeSetName() with a name longer than 2G. It will leave the node
object in an invalid state with a NULL name. This later causes a NULL
pointer dereference when using the name during message serialization.

To solve this, implement a workaround that resets the name to the
sentinel name if this situation arises.

Versions of libxml of 2.13 and higher are not affected.

This can be exploited if a SoapVar is created with a fully qualified
name that is longer than 2G. This would be possible if some application
code uses a namespace prefix from an untrusted source like from a remote
SOAP service.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-07-01 09:35:03 -07:00
Jakub Zelenka
545d1536d8
Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-07-01 09:34:49 -07:00
Jakub Zelenka
cf0c39723e
Fix GHSA-3cr5-j632-f35r: Null byte in hostnames
This fixes stream_socket_client() and fsockopen().

Specifically it adds a check to parse_ip_address_ex and it also makes
sure that the \0 is not ignored in fsockopen() hostname formatting.
2025-07-01 09:34:23 -07:00
Shivam Mathur
8ae80d2fa5
Merge branch 'PHP-8.2' into PHP-8.3 2025-06-30 20:02:10 +05:30
Shivam Mathur
c5f1ae38a2
Merge branch 'PHP-8.1' into PHP-8.2 2025-06-30 20:01:49 +05:30
Shivam Mathur
8ddc210bf7
Fix PHP_BUILD_CRT input in the nightly workflow (#18982) 2025-06-30 20:00:25 +05:30
Arnaud Le Blanc
0d9c8f66a3
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add FreeBSD ZTS nightly build
2025-06-30 11:47:55 +02:00
Arnaud Le Blanc
05a44d2813
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Add FreeBSD ZTS nightly build
2025-06-30 11:47:49 +02:00
Arnaud Le Blanc
85522c0d48
Add FreeBSD ZTS nightly build
Closes GH-18959
2025-06-30 11:47:26 +02:00
David Carlier
865739e5b1
Fix GH-18976: pack with h or H format string overflow.
adding with its own remainder, INT_MAX overflows here (negative values are
discarded).

close GH-18977
2025-06-29 16:57:10 +01:00
Arnaud Le Blanc
aee1d7fb96
Fix pcntl_rfork / pcntl_forkx with zend-max-execution-timers 2025-06-27 15:46:20 +02:00
Jakub Zelenka
7b33b1c916
Update NEWS with entries for security fixes 2025-06-26 11:24:54 +02:00
Ilija Tovilo
e892356884
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix CI for windows-2022
2025-06-25 00:20:24 +02:00
Shivam Mathur
ac15486ae0
Fix CI for windows-2022
This is a continuation of GH-18927 to fix CI for windows-2022
2025-06-25 03:20:49 +05:30
Shivam Mathur
ea6a7a9725
Fix CI for windows-2022
This is a continuation of GH-18927 to fix CI for windows-2022
2025-06-25 03:17:32 +05:30
Ahmed Lekssays
9cb3d8d200
Fix GHSA-453j-q27h-5p8x
Libxml versions prior to 2.13 cannot correctly handle a call to
xmlNodeSetName() with a name longer than 2G. It will leave the node
object in an invalid state with a NULL name. This later causes a NULL
pointer dereference when using the name during message serialization.

To solve this, implement a workaround that resets the name to the
sentinel name if this situation arises.

Versions of libxml of 2.13 and higher are not affected.

This can be exploited if a SoapVar is created with a fully qualified
name that is longer than 2G. This would be possible if some application
code uses a namespace prefix from an untrusted source like from a remote
SOAP service.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-06-24 23:32:34 +02:00
Niels Dossche
359a21f102
Fix RCN violations in array functions
When the array functions perform their operation in-place, the
`@refcount 1` annotation is wrong and causes a failure under
`ZEND_VERIFY_FUNC_INFO`.
The test file tests all functions that have the in-place optimization,
even those that didn't have the refcount annotation, just to prevent
future regressions.

Closes GH-18929.
2025-06-24 23:29:00 +02:00
Shivam Mathur
dc79f4c8c6
Merge branch 'PHP-8.2' into PHP-8.3 2025-06-25 02:01:24 +05:30
Shivam Mathur
91f2458020
Merge branch 'PHP-8.1' into PHP-8.2 2025-06-25 02:00:11 +05:30
Shivam Mathur
6233dc6210
Switch to windows-2022 in CI (#18927)
* Switch to windows-2022 in CI

windows-2019 runner will be dropped by GitHub on 2025-06-30.

* xfail test cases that fail on windows-2022
2025-06-25 01:57:07 +05:30
Jakub Zelenka
9376aeef9f
Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-06-23 23:02:13 +02:00
Jakub Zelenka
cac8f7f1cf
Fix GHSA-3cr5-j632-f35r: Null byte in hostnames
This fixes stream_socket_client() and fsockopen().

Specifically it adds a check to parse_ip_address_ex and it also makes
sure that the \0 is not ignored in fsockopen() hostname formatting.
2025-06-23 23:00:30 +02:00
Niels Dossche
1e3d92f8a9
Fix GH-14082: Segmentation fault on unknown address 0x600000000018 in ext/opcache/jit/zend_jit.c
During persisting, the JIT may trigger and fill in the call graph.
The call graph info is allocated on the arena which will be gone after preloading.
To prevent invalid accesses during normal requests, the arena data should be cleared.
This has to be done after all scripts have been persisted because shared op arrays between
scripts can change the call graph.

Closes GH-18916.
2025-06-23 22:27:36 +02:00
Niels Dossche
8e731ca622
Fix GH-18639: Internal class aliases can break preloading + JIT
ZEND_FUNC_INFO() can not be used on internal CE's. If preloading makes a
CE that's an alias of an internal class, the invalid access happens when
setting the FUNC_INFO.

While we could check the class type to be of user code, we can just skip
aliases altogether anyway which may be faster.

Closes GH-18915.
2025-06-23 20:01:15 +02:00
Niels Dossche
799ec7b8c5
Fix misleading errors in printf()
The precision and width _can_ be zero.

Closes GH-18911.
2025-06-23 19:58:49 +02:00
Niels Dossche
b50898894d
Unbreak PRINTF_DEBUG macro usages
Clearly nobody has used this in a while given the compile errors and
warnings.
This patch fixes them so there are no errors nor warnings anymore.

Closes GH-18910.
2025-06-23 19:58:19 +02:00
David Carlier
2ccd2b016d
ext/calendar: jewishtojd overflow on year argument.
Upper limit set to the 7th millenium (Messianic Age) in the jewish calendar,
 around 2239 year in the gregorian calendar.

close GH-18849
2025-06-23 11:46:10 +01:00
Niels Dossche
a5f21ca700
Fix GH-18901: integer overflow mb_split
We prevent signed overflow by making the count unsigned. The actual
interpretation of the count doesn't matter as it's just used to denote a
limit.

The test output for some limit values looks strange though, so that may
need extra investigation. However, that's orthogonal to this fix.

Closes GH-18906.
2025-06-22 13:07:43 +02:00
David Carlier
2694eb9df0
Fixed GH-18902: ldap_exop/ldap_exop_sync assert triggered on empty request OID
close GH-18903
2025-06-22 11:41:23 +01:00
Jakub Zelenka
a36b8fdc94
Fix GH-13264: fgets() and stream_get_line() do not return false on filter fatal error
This happens because there are no checks in php_stream_fill_read_buffer
calls. This should not fail always but only on fatal error so special
flag is needed for that.

Closes GH-18778
2025-06-21 20:13:09 +02:00