Commit graph

66250 commits

Author SHA1 Message Date
Niels Dossche
bf4b470098
Fix reference support for intltz_get_offset()
It should use the helper macros such that types are properly respected.

Closes GH-18364.
2025-04-20 14:23:31 +02:00
Niels Dossche
c905d59106
Fix NULL deref on high modification key
We should re-index in the loop.

Closes GH-18331.
2025-04-16 11:37:49 +02:00
Niels Dossche
91c6c727d5
Fix memory leak when handling a too long path in ZipArchive::addGlob()
Closes GH-18330.
2025-04-16 10:45:35 +02:00
Niels Dossche
0a6326c6ac
Fix uouv when handling empty options in ZipArchive::addGlob()
Reported by OpenAI AARDVARK.

php_zip_parse_option is only called when options are passed to the function.
Prior to this patch, php_zip_parse_option was responsible for zeroing the
opts variable. So in the case when php_zip_parse_option is not called,
opts remains uninitialized yet it is being used anyway.
By just always zeroing opts at declaration time, we avoid this issue
and we are unlikely to reintroduce this in the future.

Closes GH-18329.
2025-04-16 10:44:59 +02:00
Saki Takamachi
9d4f8b5379
Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted" with setAttribute() (#18280)
Closes #18280
Fixes #18276
2025-04-15 09:01:40 +09:00
haszi
701f3a1af6
Mark ob_start callback parameter nullable 2025-04-14 22:35:06 +02:00
Niels Dossche
67503870ca
Fix GH-18322: SplObjectStorage debug handler mismanages memory
This hack was once necessary before there was a proper get_gc handler,
but now it breaks the engine constraints.

Closes GH-18323.
2025-04-14 14:11:09 +02:00
Niels Dossche
8849a5336e
Fix GH-18309: ipv6 filter integer overflow
The intermediate computation can cause a signed integer overflow, but
the input is correctly rejected later on by the check on variable `n`.
Solve this by using an unsigned number.

Closes GH-18312.
2025-04-11 23:35:00 +02:00
Niels Dossche
ba0853888d
Fix GH-18304: Changing the properties of a DateInterval through dynamic properties triggers a SegFault
For dynamic fetches the cache_slot will be NULL, so we have to check for
that when resetting the cache. For zip and xmlreader this couldn't
easily be tested because of a lack of writable properties.

Closes GH-18307.
2025-04-11 23:33:58 +02:00
Niels Dossche
29f96fb1f1
Fix potential leaks when writing to BIO fails
When the BIO is created but writing fails, these can leak.

Closes GH-18186.
2025-04-11 21:02:37 +02:00
Remi Collet
389de7c6bf
Fix #17776 LDAP_OPT_X_TLS_REQUIRE_CERT can't be overridden 2025-04-10 17:07:15 +02:00
Gina Peter Banyard
61f704f269
ext/libxml: Fixed custom external entity loader returning an invalid resource leading to a confusing TypeError message
Closes GH-18096
2025-04-07 12:58:52 +01:00
David Carlier
fe8dffef5d
Fixed GH-18243: imagettftext underflow/overflow on size argument.
close GH-18245
2025-04-05 15:56:45 +01:00
Niels Dossche
8a1f6711bf
Fix resource leak in iptcembed() on error
Closes GH-18225.
2025-04-02 21:05:48 +02:00
Niels Dossche
5e68671f88
Fix inverted call to php_openssl_store_errors()
This calls php_openssl_store_errors() in the success path right now,
change it to call php_openssl_store_errors() in the error path.
2025-04-02 20:25:21 +02:00
Niels Dossche
0dc600c69a
Fix openssl_random_pseudo_bytes() always setting strong_result to true
This regressed in 62c7432f, prior to that commit the value was set to
false in case random number generation failed, but now even if an
exception is thrown it is set to true. This likely does not _really_
matter as the user will handle the exception, still the value in
$strong_result is observable.
2025-04-02 20:25:21 +02:00
Niels Dossche
74720a22f3
Fix memory leak in openssl_sign() when passing invalid algorithm
Closes GH-18185.
2025-04-02 20:15:53 +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
Niels Dossche
13d51f895b
Add missing EXTENSIONS section to intl test
[ci skip]
2025-03-31 23:05:15 +02:00
David Carlier
a1620048fb
ext/gd: imagecrop rect argument overflow fixes.
```
ext/gd/libgd/gd.c:2275:14: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
    #0 0x5d6a2103e1db in php_gd_gdImageCopy /home/dcarlier/Contribs/php-src/ext/gd/libgd/gd.c:2275
    #1 0x5d6a210a2b63 in gdImageCrop /home/dcarlier/Contribs/php-src/ext/gd/libgd/gd_crop.c:57
    #2 0x5d6a21018ca4 in zif_imagecrop /home/dcarlier/Contribs/php-src/ext/gd/gd.c:3575
    #3 0x5d6a21e46e7a in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:1337
    #4 0x5d6a221188da in execute_ex /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:57246
    #5 0x5d6a221366bd in zend_execute /home/dcarlier/Contribs/php-src/Zend/zend_vm_execute.h:61634
    #6 0x5d6a21d107a6 in zend_execute_scripts /home/dcarlier/Contribs/php-src/Zend/zend.c:1895
    #7 0x5d6a21a63409 in php_execute_script /home/dcarlier/Contribs/php-src/main/main.c:2529
    #8 0x5d6a22516d5e in do_cli /home/dcarlier/Contribs/php-src/sapi/cli/php_cli.c:966
    #9 0x5d6a2251981d in main /home/dcarlier/Contribs/php-src/sapi/cli/php_cli.c:1341
    #10 0x7f10d002a3b7 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #11 0x7f10d002a47a in __libc_start_main_impl ../csu/libc-start.c:360
    #12 0x5d6a20a06da4 in _start (/home/dcarlier/Contribs/php-src/sapi/cli/php+0x2806da4) (BuildId: d9a79c7e0e4872311439d7313cb3a81fe04190a2)
```

close GH-18006
2025-03-28 17:30:25 +00: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
Derick Rethans
0c8a7a77a8
Updated to version 2025.2 (2025b) 2025-03-24 10:06:32 +00:00
Niels Dossche
071f707a6d
[ci skip] Make sure opcache can output in these tests 2025-03-21 16:35:47 +01:00
Niels Dossche
8823f89a32
Fix intl tests for icu 77 (#18125) 2025-03-21 14:23:03 +01:00
Niels Dossche
2ec8d37eb4
Fix GH-18107: Opcache CFG jmp optimization with try-finally breaks the exception table
If there's a try-finally where the try_op starts on a basic block with a
single JMP, and the JMP optimization causes that basic block to become
unreachable, then we update try_op.
In this case, there is no catch_op, so try_op is erroneously set to 0,
we should instead set it to `b->start`.

Closes GH-18110.
2025-03-21 13:56:31 +01:00
Remi Collet
209f4c296e
Fix #66049 Typemap can break parsing in parse_packet_soap leading to a segfault 2025-03-21 08:23:12 +01:00
Niels Dossche
2dde07af55
Fix memory leak when destroying PDORow
This should call zend_object_std_dtor() to clean the property table etc.
This also has a semantic influence because previously weak refs were not
notified for example.

This fixes the final issue in GH-18114 (the crash was master-only and
fixed already).

Closes GH-18114.
Closes GH-18123.
2025-03-20 23:13:42 +01:00
Niels Dossche
e9c0296240
Fix GH-18112: NULL access with preloading and INI option
Preloading shutdown calls request shutdown which will deactivate the
virtual cwd state. However, further startup code still assumes the state
that was set by virtual_cwd_startup(). So we need to reactivate it
manually.

Creating a test was a bit difficult because the INI setting I wanted to
test this with is overridden by the test runner apparently.
To reproduce the issue, create an empty file test.php and execute this
in a ZTS build:
`php -d opcache.preload=./ext/opcache/tests/preload_class_alias_2.inc -d "error_log=" -d "allow_url_include=1" test.php`

Closes GH-18117.
2025-03-20 19:12:06 +01:00
Niels Dossche
d9329b1522
Fix xinclude destruction of live attributes
Follow-up for GH-17847 but now for attributes.

Closes GH-18100.
2025-03-18 22:01:56 +01:00
Jakub Zelenka
bd7d3c38ad
Get rid of atime change testing in bug72666_variation3.phpt 2025-03-17 14:49:22 +01:00
David Carlier
005c7b5797
ext/intl: Fix Uconverter::transcode with substitutes as references.
close GH-18059
2025-03-15 11:37:08 +00:00
David Carlier
f34859cb90
ext/intl: Fix dateformat_format when the time is an array of references. 2025-03-15 11:33:17 +00:00
Arnaud Le Blanc
1c182674b0
Destroy temporary module classes in reverse order
We destroy classes of dl()'ed modules in clean_module_classes(), during
shutdown. Child classes of a module use structures of the parent class (such as
inherited properties), which are destroyed earlier, so we have a use-after-free
when destroying a child class.

Here I destroy classes in reverse order, as it is done in zend_shutdown() for
persistent classes.

Fixes GH-17961
Fixes GH-15367
2025-03-14 10:45:17 +01:00
Niels Dossche
a7d2703246
Correct check for maximum string length in JIT helpers
This is a bit of a theoretical issue, but the maximum string length is
actually ZSTR_MAX_LEN instead of SIZE_MAX. The resulting check is a bit
slower but should still be relatively cheap.

Closes GH-18049.
2025-03-13 23:47:45 +01:00
Niels Dossche
27affd8da1
Fix GH-18018: RC1 data returned from offsetGet causes UAF in ArrayObject
We should first check truthiness and only after that destroy the value.

Closes GH-18034.
2025-03-13 19:10:34 +01:00
Ilija Tovilo
276c2a67ef
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix flaky connection count in mysqli test
2025-03-13 16:47:20 +01:00
Ilija Tovilo
f390425db3
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix flaky connection count in mysqli test
2025-03-13 16:46:03 +01:00
Ilija Tovilo
00ebd2d7f2
Fix flaky connection count in mysqli test
Use connection ID instead of count to check whether we're using a
persistent connection. This allows the test to be run in parallel with
the other tests, but also protects against the possibility that some
other service connects to the mysql server.

Closes GH-18040
2025-03-13 16:40:33 +01:00
Remi Collet
69480be12a
Relax test expectation for pcre2lib 10.45 Using e92848789a
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-03-13 07:46:18 +01:00
David Carlier
c3fc94c4b8
ext/intl: fix locale_compose/locale_lookup to be able to deal with references.
close GH-18035
2025-03-12 22:18:34 +00: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
Niels Dossche
0e715e71d9
Fix GHSA-wg4p-4hqh-c3g9 2025-03-11 21:50:17 +01:00
Tim Düsterhus
b6004a043c
Fix GHSA-p3x9-6h7p-cgfc: libxml streams wrong content-type on redirect
libxml streams use wrong content-type header when requesting a
redirected resource.
2025-03-11 21:50:17 +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
Niels Dossche
1befdce0e6
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix test GH-16535 for libxml2 2.14
  Fix tests for libxml2 2.14
2025-03-10 20:23:36 +01:00