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

66401 Commits

Author SHA1 Message Date
Alexandre Daubois
9eedf00206 Fix intl tests naming (#19763) 2025-09-09 08:41:20 +02:00
Niels Dossche
f6878b6ccf Fix GH-19752: Phar decompression with invalid extension can cause UAF
The rename code can error out prior to the reassignment of the filename,
which is why the test causes a crash.
The rename code can also error out at a later point,
which means it will have already assigned the new filename.
We detect in which case we are in and act accordingly.

Closes GH-19761.
2025-09-08 23:10:33 +02:00
Niels Dossche
ff84cb08ef Fix OSS-Fuzz #385993744
PSFS_FEED_ME is supposed to be returned when the filter did not receive
enough data and did not generate buckets for the output brigade.
The test generates buckets anyway on the output brigade, and the stream
layer did not handle that case causing a memory leak.
To solve this, discard any such buckets as it would conflict with the
status code returned by the filter. This keeps BC and solves the leak.

Closes GH-18972.
2025-09-08 19:10:22 +02:00
Niels Dossche
98bb934685 Fix memory leak on failure in phar_convert_to_other()
Closes GH-19755.
2025-09-08 19:06:11 +02:00
Niels Dossche
c50b37d231 Fix metadata leak when phar convert logic fails
Closes GH-19756.
2025-09-08 19:05:47 +02:00
Alexandre Daubois
6a2adcd8a4 Fix GH-11952: better locale strings canonicalization for IntlDateFormatter and NumberFormatter (#19593) 2025-09-08 16:36:27 +02:00
David Carlier
93865a4086 Fix GH-19578: imagefilledellipse underflow on width argument.
close GH-19579
2025-09-07 18:18:17 +01:00
Niels Dossche
2f162214e8 Fix memory leak in phar tar temporary file error handling code
Closes GH-19740.
2025-09-07 13:04:19 +02:00
Niels Dossche
9d69ab91ab Fix GH-19720: Assertion failure when error handler throws when accessing a deprecated constant
When deprecation causes an exception, we should return NULL instead of
continuing.

Closes GH-19723.
2025-09-06 00:00:52 +02:00
Niels Dossche
216e87ad7e Fix memory leak in zip when encountering empty glob result
The case of returning 0 is inconsistent in when it returns an empty
array, furthermore the caller already returns an empty array.
Because the caller overwrites the return value in these cases, it can
cause a memory leak.

This is easier to trigger on master in some cases as different code paths
are taken with the new bundled glob. On some platforms it is also
triggerable on 8.3.

Closes GH-19715.
2025-09-05 18:56:27 +02:00
Alexandre Daubois
05133ac962 Fix GH-19577: avoid integer overflow when using a small offset and PHP_INT_MAX with LimitIterator (#19585) 2025-09-05 08:09:06 +02:00
Niels Dossche
080fd14458 Fix GH-19612: Mitigate libxml2 tree dictionary bug
This code is very similar to code on PHP 8.4 and higher, but the
mitigation is extended to entity references and to attribute children.

Closes GH-19620.
2025-09-03 21:52:48 +02:00
Ilija Tovilo
0ae9a58ade Fix date_sunrise() and date_sunset() with partial-hour UTC offset
See GH-19633
Closes GH-19672
2025-09-03 13:34:03 +02:00
Gina Peter Banyard
f5a3a642c6 ext/phar: Fix memory leaks when verifying OpenSSL signature (#19563) 2025-08-23 14:25:42 +01:00
Arnaud Le Blanc
d74901ae1a Differenciate WeakMaps from bare HashTables used as weak maps for GC purposes
Since cbf67e4, the GC needs to find all WeakMaps referencing a weakly
referenced object. Doing so, it treats all ZEND_WEAKREF_TAG_MAP as WeakMap
instances.

However, a ZEND_WEAKREF_TAG_MAP reference may be a bare HashTable when
zend_weakrefs_hash_add() is used.

Introduce a new tag, ZEND_WEAKREF_TAG_BARE_HT, and use this tag when weakly
referencing an object from a bare HashTable. Ignore such references in GC.

Fixes GH-19543
Closes GH-19544

Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
2025-08-22 16:32:30 +02:00
Arjen de Korte
a97717d23e Fix GH-19021: deprecation for tidyOptIsReadOnly
The tidyOptGetCategory function (added in libtidy 5.4.0) if only useable if TidyInternalCategory (added in libtidy 5.6.0) is also present, so check for the latter instead.

close GH-19053
2025-08-16 19:24:47 +01:00
Mark Karpeles
987a3a5c8e Fix GH-19484 i: potential use after free when using persistent pgsql connections.
By setting the notice processor to a no-op when a persistent connection is cleaned for future use.

Close GH-19485
2025-08-15 08:04:14 +01:00
Ilija Tovilo
a3de2ce9ba Fix "Constant already defined" warning with repeated inclusion of file with __halt_compiler()
Fixes GH-18850
Closes GH-19471
2025-08-14 12:13:50 +02:00
Alexandre Daubois
c8774f9e61 Fix GH-16649: Avoid UAF when using array_splice
Closes GH-19399
2025-08-13 14:15:34 +02:00
Jakub Zelenka
2b415e416e Fix GH-19245: Success error message on TLS stream accept failure
This overwrites the previous message from the successful accept call.

Closes GH-19246
2025-08-12 17:28:33 +02:00
Jakub Zelenka
9e2aa658a8 Fix GH-19428: openssl_pkey_derive segfaults for DH derive with low key_length
This happens only for OpenSSL 1.1.1 because key_length is ignored for
DH. It means that the provided string is overwritten with longer buffer.
2025-08-09 17:43:04 +02:00
Niels Dossche
cc93bbb765 Fix GH-19397: mb_list_encodings() can cause crashes on shutdown
The request shutdown does not necessarily hold the last reference, if
there is still a CV that refers to the array.

Closes GH-19405.
2025-08-08 20:32:29 +02:00
Niels Dossche
5cf45ba5ab Fix GH-19371: integer overflow in calendar.c
Closes GH-19380.
2025-08-07 19:08:32 +02:00
Ilija Tovilo
5be04e25fd [skip ci] Skip segfaulting OOM test in GH actions on Win
This only fails on the PHP-8.3 branch, most likely to be related to the
environment as discussed with Niels.
2025-08-06 14:28:47 +02:00
Niels Dossche
a96b05e63f Fix GH-19300: Nested array_multisort invocation with error breaks
There are 2 issues:
1. When a MULTISORT_ABORT happens, it frees func, but func may point to
   ARRAYG(multisort_func), which would be a problem with nested
   invocations as it can destroy that of the "parent" invocation.
   To solve this, delay assigning to the globals.
2. The old globals were not restored which means that nested invocations
   with different flags will cause a wrong sorting function to be used.

Closes GH-19319.
2025-07-31 19:00:45 +02:00
Niels Dossche
be9f1d3d56 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Reset global pointers to prevent use-after-free
2025-07-30 09:23:12 +02:00
Niels Dossche
7016ad558b Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Reset global pointers to prevent use-after-free
2025-07-30 09:22:50 +02:00
Florian Engelhardt
3aaa8d3526 Reset global pointers to prevent use-after-free
Closes GH-19212.
2025-07-30 09:22:15 +02:00
Gina Peter Banyard
6b0a80903b ext/intl: Fix return value on failure for resourcebundle count handler
Closes GH-19277
2025-07-28 15:35:31 +01:00
Gina Peter Banyard
83b8d2c290 ext/gd: Fix comparison with result of php_stream_can_cast()
Closes GH-19107
2025-07-28 11:54:19 +01:00
Peter Kokot
17df11e3f7 Fix bug #51558: shared readline build fails (#15242)
The 'rl_pending_input' is a variable in Readline library and checking it
with PHP_CHECK_LIBRARY wouldn't find it on some systems.

Library check works on most systems but not on the mentioned AIX in the
bug as it exports variables and functions differently whereas the linker
couldn't resolve the variable as a function.

This should fix the build on systems where this caused issues, such as
AIX.

The <readline/readline.h> is not self-contained header and needs to also
have <stdio.h> included before to have FILE type available. This fixes
the issue on unpatched default readline installations, such as macOS.

Checking this variable ensures that the found library is the correct
library and also that it is of minimum version needed by current PHP
code (https://bugs.php.net/48608).

The library check:

```c
| char rl_pending_input ();
| int main (void) {
|     return rl_pending_input ();
| }
```

The declaration check:

```c
| #include <stdio.h>
| #include <readline/readline.h>
| int main (void) {
| #ifndef rl_pending_input
| #ifdef __cplusplus
|     (void) rl_pending_input;
| #else
|     (void) rl_pending_input;
| #endif
| #endif
| ;
|     return 0;
| }
```

Closes https://bugs.php.net/51558

Closes GH-19259.
2025-07-27 15:33:48 +02:00
David Carlier
e1c4a0ae51 Fixed GH-19261: msgfmt_parse_message leaks on message format failure.
close GH-19262
2025-07-27 13:49:24 +01:00
dixyes
e16df981bf ext/pdo_pgsql: Fix _pdo_pgsql_trim_message bad access
close GH-19239
2025-07-27 12:54:43 +01:00
Niels Dossche
beeeee2978 Handle broken hrtime in ftp
Part of GH-19210.

Closes GH-19219.
2025-07-25 11:56:30 +02:00
Niels Dossche
ad2143f3b0 Fix arginfo/zpp violation if zend_hrtime is not available
Part of GH-19210.

Closes GH-19218.
2025-07-25 11:56:17 +02:00
Niels Dossche
7efbb2e4e0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Run FreebSD CI under 13.5
2025-07-22 15:52:29 +02:00
Niels Dossche
d9d412645d Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Run FreebSD CI under 13.5
2025-07-22 15:52:16 +02:00
Niels Dossche
be88192594 Run FreebSD CI under 13.5
13.3 gives a 404 now.
Also pulls in a 8.4 fix to include xxhash from the bundled location.

Closes GH-19213.
2025-07-22 15:51:19 +02:00
Ilija Tovilo
5d1636e40b Leak in failed unserialize() with opcache
With opcache, zend_string_init_interned() will allocate non-interned strings at
runtime because shm is locked. Hence, we need to make sure to actually free this
string.

Fixes OSS-Fuzz #433303828
Closes GH-19211
2025-07-22 15:43:31 +02:00
Niels Dossche
7ab37e81e0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix test conflict between chmod_variation2 and file_variation5
2025-07-21 23:57:42 +02:00
Niels Dossche
27f24bd9bc Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix test conflict between chmod_variation2 and file_variation5
2025-07-21 23:57:34 +02:00
Niels Dossche
605ee05491 Fix test conflict between chmod_variation2 and file_variation5
Both used "somelink".
See https://github.com/php/php-src/actions/runs/16427526464/job/46421461376

Closes GH-19208.
2025-07-21 23:57:21 +02:00
Niels Dossche
6cc4ae1f1d Fix GH-18640: heap-use-after-free ext/soap/php_encoding.c:299:32 in soap_check_zval_ref
For attributes, relying on the ref_map doesn't make sense the first
place as you can't really refer to attributes from attributes.
The code therefore assumes that the node is unique, which is broken.

Closes GH-19181.
2025-07-20 19:49:22 +02:00
Niels Dossche
312869381a Fix GH-19098: libxml<2.13 segmentation fault caused by php_libxml_node_free
This implements a workaround for reconciliation not being performed for
document-less nodes in libxml<2.13.

Closes GH-19186.
2025-07-20 17:19:43 +02:00
Niels Dossche
d11099ae32 ext/socket: Remove incorrect zval_ptr_dtor 2025-07-17 21:50:35 +02:00
Niels Dossche
bdca73cc14 ext/hash: Remove incorrect zval_ptr_dtor 2025-07-17 21:50:35 +02:00
Jakub Zelenka
8516ae86d7 Skip LDAP TLS max version test for now 2025-07-17 13:44:21 +02:00
Niels Dossche
034c3f2270 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ext/xml: Suppress libxml deprecation for `_xmlParserCtxt.inState` (#19131)
2025-07-16 18:26:54 +02:00
Niels Dossche
9eee4dd92b Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  ext/xml: Suppress libxml deprecation for `_xmlParserCtxt.inState` (#19131)
2025-07-16 18:24:55 +02:00
Tim Düsterhus
a5df26691d ext/xml: Suppress libxml deprecation for _xmlParserCtxt.inState (#19131)
The FreeBSD build fails due to the deprecation and -Werror:

    2025-07-15T00:37:20.8390774Z /home/runner/work/php-src/php-src/ext/xml/compat.c:358:38: error: 'instate' is deprecated [-Werror,-Wdeprecated-declarations]
    2025-07-15T00:37:20.8392577Z   358 |                 if (ret == NULL || parser->parser->instate == XML_PARSER_CONTENT) {
    2025-07-15T00:37:20.8393184Z       |                                                    ^
    2025-07-15T00:37:20.8394006Z /usr/local/include/libxml2/libxml/parser.h:309:33: note: 'instate' has been explicitly marked deprecated here
    2025-07-15T00:37:20.8394903Z   309 |     xmlParserInputState instate XML_DEPRECATED_MEMBER;
    2025-07-15T00:37:20.8395413Z       |                                 ^
    2025-07-15T00:37:20.8396166Z /usr/local/include/libxml2/libxml/xmlexports.h:74:50: note: expanded from macro 'XML_DEPRECATED_MEMBER'
    2025-07-15T00:37:20.8397058Z    74 |     #define XML_DEPRECATED_MEMBER __attribute__((deprecated))
    2025-07-15T00:37:20.8397581Z       |                                                  ^
    2025-07-15T00:37:20.8425542Z 1 error generated.
2025-07-16 18:23:54 +02:00