Commit Graph

13938 Commits

Author SHA1 Message Date
David CARLIER
e787d9a0dc GH-9370: Fix opcache jit protection bits.
Allow mprotect to occur, pthread_jit_write_np are just to allow mprotect
 flags to be used.

Closes #9371.
2022-08-24 16:11:35 +01:00
Tim Düsterhus
0f696e2934
Fix rand_range32() for umax = UINT32_MAX (#9416)
* Fix rand_range32() for umax = UINT32_MAX

This was introduced in the commit that added the random extension:
4d8dd8d258.

Resolves GH-9415

* [ci skip] Rename `$r` to `$randomizer` in gh9415.phpt

* Make gh9415.phpt deterministic

* Make gh9415.phpt compatible with 32-bit
2022-08-24 14:25:51 +02:00
Máté Kocsis
0897266219
Fix GH-9285 Traits cannot be used in readonly classes 2022-08-21 10:33:08 +02:00
George Peter Banyard
d766e91681 Merge branch 'PHP-8.1' 2022-08-19 13:57:59 +01:00
George Peter Banyard
eb8ea14c66 Merge branch 'PHP-8.0' into PHP-8.1 2022-08-19 13:57:19 +01:00
George Peter Banyard
d6831e9a5c Revert Fixed bug #79451
The fix for 8.1 and above is not identical and I don't know how to fix without breaking the whole build apparently
2022-08-19 13:54:54 +01:00
Christoph M. Becker
a1f5c8a587
Fix GH-9227: Trailing dots and spaces in filenames are ignored
Given that Windows ignores trailing dots and spaces in filenames, we
catch that ourselves to avoid confusion with the respective filenames
without these characters.

Closes GH-9229.
2022-08-19 14:23:57 +02:00
George Peter Banyard
6a7935351b Merge branch 'PHP-8.1' 2022-08-19 12:55:12 +01:00
George Peter Banyard
c36a1ea1ae Merge branch 'PHP-8.0' into PHP-8.1 2022-08-19 12:52:58 +01:00
Tim Starling
ba029fce68 Fix GH-9323: crash when the VM enters userspace code via the GC
Closes GH-9323
2022-08-19 12:50:02 +01:00
NathanFreeman
1d4300d870 Fix bug #79451: Using DOMDocument->replaceChild on doctype causes double free
Closes GH-9201
2022-08-19 12:46:23 +01:00
Christoph M. Becker
5d196d9e7c
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9316: $http_response_header is wrong for long status line
2022-08-18 12:30:45 +02:00
Christoph M. Becker
72da418719
Fix GH-9316: $http_response_header is wrong for long status line
While the reason-phrase in a HTTP response status line is usually
short, there is no actual limit specified by the RFCs.  As such, we
must not assume that the line fits into the buffer (which is currently
128 bytes large).

Since there is no real need to present the complete status line, we
simply read and discard the rest of a long line.

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>

Closes GH-9319.
2022-08-18 12:27:54 +02:00
Jakub Zelenka
93bed982e8
Merge branch 'PHP-8.0' into PHP-8.1 2022-08-17 19:50:16 +01:00
Jakub Zelenka
84dcf578b1
Fix GH-9339: OpenSSL oid_file path check warning contains uninitialized path 2022-08-17 19:49:36 +01:00
Gabriel Caruso
7c6316ad1c
Prepare for 8.0.24 2022-08-17 11:56:42 +02:00
Ben Ramsey
7f26661993
PHP-8.1 is now for PHP 8.1.11-dev 2022-08-16 10:45:29 -05:00
Pierrick Charron
a0455fe716
[ci skip] Update NEWS for PHP 8.2.0 RC1 2022-08-16 11:39:53 -04:00
twosee
fa83e37e73
[ci skip] Add missing NEWS entry for GH-9324 2022-08-15 23:59:58 +08:00
Christoph M. Becker
306da80f56
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Correct IntlDateFormatter::formatObject params
2022-08-15 17:58:52 +02:00
Gert de Pagter
05ed47ef12
Correct IntlDateFormatter::formatObject params
Closes GH-9341.
2022-08-15 17:56:34 +02:00
Jakub Zelenka
7f64a8d59f
[skip ci] Add missing NEWS entry for GH-8409 fix to PHP-8.1 branch (skip-ci) 2022-08-14 14:18:28 +01:00
twosee
b8d07451d4
Re-fix GH-8409: SSL handshake timeout persistent connections hanging
This fix is another solution to replace d0527427be, use zend_try and zend_catch to make sure persistent stream will be released when error occurred.

Closes GH-9332.
2022-08-14 20:13:36 +08:00
Jakub Zelenka
897ca85d33
Revert "Fix GH-8409: SSL handshake timeout persistent connections hanging"
This reverts commit d0527427be.

This patch makes Swoole/Swow can not work anymore, because Coroutine will yield to another one during socket operation, EG(record_errors) assertion will always fail, and zend_begin_record_errors() was only used during compile time before.
Note: zend_emit_recorded_errors() and the typo fix are reserved.
2022-08-14 19:41:06 +08:00
Tim Düsterhus
b825756317
Update expires format for session cookie (#9304)
* Update expires format for session cookie

see GH-9200
see 15e3fcb468

* Add ext/session/tests/gh9200.phpt
2022-08-12 19:52:04 +02:00
Jakub Zelenka
d0527427be
Fix GH-8409: SSL handshake timeout persistent connections hanging
This is not actually related to SSL handshake but stream socket creation
which does not clean errors if the error handler is set. This fix
prevents emitting errors until the stream is freed.
2022-08-12 17:09:24 +01:00
Christoph M. Becker
71c22efae7
Fix GH-9309: Segfault when connection is used after imap_close()
We actually need to check whether `php_imap_object.imap_stream` is
`NULL` to detect that the connection has already been closed.

Closes GH-9313.
2022-08-12 16:24:30 +02:00
Christoph M. Becker
7908aae30c
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9296: `ksort` behaves incorrectly on arrays with mixed keys
2022-08-12 11:36:24 +02:00
Denis Vaksman
cd1aed8edd
Fix GH-9296: ksort behaves incorrectly on arrays with mixed keys
The comparator function used at ksort in SORT_REGULAR mode
need to be consistent with basic comparison rules. These rules
were changed in PHP-8.0 for numeric strings, but comparator
used at ksort kept the old behaviour. It leads to inconsistent
situations, when after ksort the first key is GREATER than some
of the next ones by according to the basic comparison operators.

Closes GH-9293.
2022-08-12 11:32:23 +02:00
Derick Rethans
15e3fcb468 Fixed GH-9200: setcookie has an obsolete expires date format 2022-08-11 16:27:25 +01:00
Michael Olšavský
0709578517
Fix GH-9266: GC root buffer keeps growing when dtors are present
Do not reset cleared count on GC rerun.

Closes GH-9265.
2022-08-09 14:16:11 +02:00
Tyson Andre
6a50af2604
Make "{$g{'h'}}" emit fatal error and no incorrect deprecation notice in 8.2 (#9264)
The ast node flag constants ZEND_DIM_ALTERNATIVE_SYNTAX and
ZEND_ENCAPS_VAR_DOLLAR_CURLY_VAR_VAR node have identical values (1<<1),
causing a deprecation notice to be incorrectly emitted before the fatal error
for unsupported syntax.

Fixes GH-9263

Explicitly check for AST_VAR/AST_DIM kind for future compatibility

`AST_PROP`/`AST_METHOD_CALL` and nullsafe variants can also be found in
encapsulated strings - currently they have no flags but they may have flags in
the future. This also clarifies that this deprecation warning can only happen
for AST_VAR/AST_DIM nodes for certain `attr` values.
2022-08-08 19:41:32 -04:00
Christoph M. Becker
d013d94985
Fix GH-9248: Segmentation fault in mb_strimwidth()
We need to initialize the optional argument `trimmarker` with its
default value.

Closes GH-9273.
2022-08-08 18:35:37 +02:00
Jakub Zelenka
c9fa98a174
Merge branch 'PHP-8.0' into PHP-8.1 2022-08-07 14:21:39 +01:00
Jakub Zelenka
d9ff5e079f
Fix GH-8472: stream_socket_accept result may have incorrect metadata 2022-08-07 14:17:38 +01:00
Christoph M. Becker
ad04345eb3
Fix GH-9244: Segfault with array_multisort + array_shift
After restructuring non-packed arrays, we either need to pack them if
possible, or to rehash them.

Closes GH-9247.
2022-08-05 17:09:54 +02:00
zeriyoshi
19eecf16aa [ci skip] update NEWS
--CGI-- fixes for PHP 8.1 / 8.0
30ed8fb32d
2022-08-06 00:03:57 +09:00
Tim Düsterhus
1cd2d731ef
Handle all-zero state in Xoshiro256** (#9250)
- Retry if the CSPRNG generates a zero state.
- Throw ValueError if the user passes a zero state.

Fixes GH-9249
2022-08-05 14:38:57 +02:00
sji
038c451c22
[ci skip] NEWS and UPGRADING for constants in traits (#9251)
see GH-8888
2022-08-04 23:18:50 +02:00
zeriyoshi
30ed8fb32d Merge remote-tracking branch 'upstream/PHP-8.1' 2022-08-05 00:08:36 +09:00
zeriyoshi
2d777466c0 Merge remote-tracking branch 'upstream/PHP-8.0' into PHP-8.1 2022-08-05 00:06:04 +09:00
zeriyoshi
1ce2b56227 [CI skip] update NEWS 2022-08-05 00:05:12 +09:00
Go Kudo
3725717de1
Remove ZEND_DVAL_TO_LVAL_CAST_OK (#9215)
* Remove ZEND_DVAL_TO_LVAL_CAST_OK
As far as I can see, this operation should always use the _slow method, and the results seem to be wrong when ZEND_DVAL_TO_LVAL_CAST_OK is enabled.

* update NEWS
2022-08-04 23:56:19 +09:00
Tim Düsterhus
60ace13f9c
Fix undefined behavior of MT_RAND_PHP if range exceeds ZEND_LONG_MAX (#9197)
RAND_RANGE_BADSCALING() invokes undefined behavior when (max - min) >
ZEND_LONG_MAX, because the intermediate `double` might not fit into
`zend_long`.

Fix this by inlining a fixed version of the macro into Mt19937's range()
function. Fixing the macro itself cannot be done in the general case, because
the types of the inputs are not known. Instead of replacing one possibly broken
version with another possibly broken version, the macro is simply left as is
and should be removed in a future version.

The fix itself is simple: Instead of storing the "offset" in a `zend_long`, we
use a `zend_ulong` which is capable of storing the resulting double by
construction. With this fix the implementation of this broken scaling is
effectively identical to the implementation of php_random_range from a data
type perspective, making it easy to verify the correctness.

It was further empirically verified that the broken macro and the fix return
the same results for all possible values of `r` for several distinct pairs of
(min, max).

Fixes GH-9190
Fixes GH-9191
2022-08-03 18:46:36 +02:00
Tim Düsterhus
3331832b04
Add ext/random Exception hierarchy (#9220)
* Add Random\Random{Error,Exception} and Random\BrokenRandomEngineError

* Throw BrokenRandomEngineError

* Throw RandomException on seeding failure

* Throw RandomException when CSPRNG fails

* Remove unused include from ext/random/engine_combinedlcg.c

* Remove unused include from ext/random/engine_secure.c

* Remove unused include from ext/random/random.c

* [ci skip] Add ext/random Exception hierarchy to NEWS

* [ci skip] Add the change of Exception for random_(int|bytes) to UPGRADING
2022-08-02 20:04:28 +02:00
Jakub Zelenka
e5ab9f45d5
Fix bug #65489: glob() basedir check is inconsistent
This removes the inconsistent and incorrectly working open basedir check
on pattern in glob. It means that an empty array will be returned even
if the whole pattern is outside the open basedir restriction.
2022-08-02 18:36:29 +01:00
Tim Düsterhus
db84e44607
Fix PcgOneseq128XslRr64::__construct() definition in random.stub.php (#9235)
* Fix PcgOneseq128XslRr64::__construct() definition in random.stub.php

The second parameter does not actually exist for a Oneseq PCG. It was removed
from the RFC before it went into voting.

* [ci skip] Add PcgOneseq128XslRr64 stub fix to NEWS
2022-08-02 18:54:39 +02:00
Tim Düsterhus
822881b6fe [ci skip] Move the removal of the RuntimeException in ext/random to Beta 3
Didn't realize that Beta 2 was tagged before merging GH-9211 /
54e406cc50.
2022-08-02 17:37:47 +02:00
Tim Düsterhus
54e406cc50
Clean up nested exceptions without value-add in ext/random (#9211)
* Remove exception in Randomizer::shuffleBytes()

The only way that `php_binary_string_shuffle` fails is when the engine itself
fails. With the currently available list of engines we have:

- Mt19937            : Infallible.
- PcgOneseq128XslRr64: Infallible.
- Xoshiro256StarStar : Infallible.
- Secure             : Practically infallible on modern systems.
                       Exception messages were cleaned up in GH-9169.
- User               : Error when returning an empty string.
                       Error when seriously biased (range() fails).
                       And whatever Throwable the userland developer decides to use.

So the existing engines are either infallible or throw an Exception/Error with
a high quality message themselves, making this exception not a value-add and
possibly confusing.

* Remove exception in Randomizer::shuffleArray()

Same reasoning as in the previous commit applies.

* Remove exception in Randomizer::getInt()

Same reasoning as in the previous commit applies.

* Remove exception in Randomizer::nextInt()

Same reasoning as in the previous commit applies, except that it won't throw on
a seriously biased user engine, as `range()` is not used.

* Remove exception in Randomizer::getBytes()

Same reasoning as in the previous commit applies.

* Remove exception in Mt19937::generate()

This implementation is shared across all native engines. Thus the same
reasoning as the previous commits applies, except that the User engine does not
use this method. Thus is only applicable to the Secure engine, which is the
only fallible native engine.

* [ci skip] Add cleanup of Randomizer exceptions to NEWS
2022-08-02 17:29:36 +02:00
Sergey Panteleev
6a7fd48aae
[ci skip] Update NEWS for PHP 8.2.0 beta3 2022-08-02 17:00:47 +03:00