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

139913 Commits

Author SHA1 Message Date
Niels Dossche
2aeefb13be Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix phar crash and file corruption with SplFileObject
2025-07-05 21:44:34 +02:00
Niels Dossche
405be1c940 Fix phar crash and file corruption with SplFileObject
There are two bugfixes here.
The first was a crash that I discovered while working on GH-19035.
The check for when a file pointer was still occupied was wrong, leading
to a UAF. Strangely, zip got this right.

The second issue was that even after fixing the first one, the file
contents were garbage. This is because the file write offset for the
phar stream was wrong.

Closes GH-19038.
2025-07-05 21:44:12 +02:00
Niels Dossche
50a5a6f315 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix stream double free in phar
2025-07-05 21:31:50 +02:00
Niels Dossche
32344c4dc4 Fix stream double free in phar
The copy function does two things wrong:
- The error recovery logic is a hack that temporarily moves the fp
  pointer to cfp, even though it's not compressed. The respective error
  recovery it talks about is not present in the code, nor is it
  necessary. This is the direct cause of the double free in the original
  reproducer. Fixing this makes it crash in another location though.
- The link following logic is inconsistent and illogical. It cannot be a
  link at this point.

The root cause, after fixing the above issues, is that the file pointers
are not reset properly for the copy. The file pointer need to be the
original ones to perform the copy from the right source, but after that
they need to be set properly to NULL (because fp_type == PHAR_FP).

Closes GH-19035.

Co-authored-by: Yun Dou <dixyes@gmail.com>
2025-07-05 21:31:28 +02:00
Niels Dossche
1af7d8e547 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OSS-Fuzz #428983568 and #428760800
2025-07-04 23:58:33 +02:00
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
2cb292de6b Merge branch 'PHP-8.3' into PHP-8.4 2025-07-03 10:35:50 -05: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
Saki Takamachi
f512cffcd0 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18873 - Free column->descid appropriately (#18957)
2025-07-03 21:24:56 +09: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
764154dc75 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18990, bug #81029, bug #47314: SOAP HTTP socket not closing on object destruction
  Fix leak when path is too long in ZipArchive::extractTo()
  curl: Remove incorrect string release on error
2025-07-02 18:46:37 +02: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
Saki Takamachi
d5fe1bce63 PHP-8.4 is now for PHP 8.4.11-dev 2025-07-02 11:39:33 +09:00
Ben Ramsey
881ec133d9 Merge branch 'PHP-8.3' into PHP-8.4 2025-07-01 15:21:57 -05: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
7a3c0d3519 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  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
2025-07-01 19:58:36 +03: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
5d590a1e87 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OSS-Fuzz #427814456
2025-07-01 18:52:39 +02:00
Niels Dossche
1d5089e574 Fix GH-18979: DOM\XMLDocument::createComment() triggers undefined behavior with null byte
Closes GH-18983.
2025-07-01 18:51:21 +02: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
Eric Mann
7f5d491a05 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  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
2025-07-01 09:39:53 -07: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
Ilija Tovilo
c57ec92eb6 Fix missing HAVE_JIT guard
Closes GH-18993
2025-07-01 17:44:11 +02:00
Ahmed Lekssays
a179e39c38 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 23:01:17 +09:00
Jakub Zelenka
66bd809ac9 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 23:01:16 +09:00
Jakub Zelenka
5ef0dc7666 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 23:01:16 +09:00
Niels Dossche
53f2aa93ae Fix GH-18898: SEGV zend_jit_op_array_hot with property hooks and preloading
Property hooks were not handled for JIT+trait+preloading.
Split the existing functions that handle op arrays, and add iterations
for property hooks.

Closes GH-18923.
2025-06-30 18:38:11 +02:00
Shivam Mathur
cb4940051a Merge branch 'PHP-8.3' into PHP-8.4 2025-06-30 20:02:45 +05:30
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
562660df9b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add FreeBSD ZTS nightly build
2025-06-30 11:48:01 +02:00
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