Commit Graph

13953 Commits

Author SHA1 Message Date
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
Gabriel Caruso
a08ffc7052
[ci-skip] Fix for bug #80047 was included in previous release
We are removing the entry in 8.0.23, as the fix was included
in the 8.0.22 release. Given that an entry already exists, we
are just deleting extra lines.
2022-08-02 10:32:06 +02:00
Arnaud Le Blanc
5d5d9796fc [ci skip] NEWS 2022-08-01 19:34:28 +02:00
Arnaud Le Blanc
832e0ef31f [ci skip] NEWS 2022-08-01 19:32:02 +02:00
Tim Düsterhus
5e518c0552 [ci skip] Move 'Core' into the correct alphabetical order in NEWS
see f957e3e7f1
2022-08-01 17:39:12 +02:00
Tim Düsterhus
09e261e3b4 [ci skip] Update NEWS for ext/random
This adds 50bd8ba51c and fixes the formatting for
two other entries.
2022-08-01 17:39:05 +02:00
zeriyoshi
4e92c74654
random: split Randomizer::getInt() without argument to Randomizer::nextInt()
Since argument overloading is not safe for reflection, the method needed
to be split appropriately.

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

Closes GH-9057.
2022-08-01 12:19:22 +02:00
Nicolas Grekas
dd9f47758e
Declare Transliterator::$id as readonly to unlock subclassing it
Closes GH-9167.
2022-08-01 10:46:57 +02:00
Ilija Tovilo
f957e3e7f1
Fix arrow function with never return type
Fixes GH-7900
Closes GH-9103
2022-07-29 12:25:09 +02:00
Ilija Tovilo
565a416e87
Fix attribute target validation on fake closures
Fixes GH-8982
Closes GH-9173
2022-07-29 12:14:44 +02:00
Derick Rethans
a50499bbaf Merge branch 'PHP-8.1' 2022-07-28 15:15:15 +01:00
Derick Rethans
a0c01f385c Add test case for GH-9601: DateInterval 1.5s added to DateTimeInterface is rounded down since PHP 8.1.0 2022-07-28 11:55:35 +01:00
Jakub Zelenka
1a9e6895f1
Fix #65069: GlobIterator incorrect handling of open_basedir check
This PR changes the glob stream wrapper so it impacts "glob://"
streamsas well. The idea is to do a check for each found path instead
of the pattern which was not working correctly.
2022-07-28 11:42:42 +01:00
Derick Rethans
001e7dbb04 Fixed bug #80047 (DatePeriod doesn't warn with custom DateTimeImmutable) 2022-07-28 10:28:10 +01:00
jcm
520bb2ec6c
Fix get/set priority - error handling for MacOS and extra tests
Closes GH-9044.
2022-07-27 13:53:42 +02:00
Christoph M. Becker
ca84d06bbc
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9032: SQLite3 authorizer crashes on NULL values
2022-07-27 13:06:15 +02:00
Christoph M. Becker
8ed21a89f3
Fix GH-9032: SQLite3 authorizer crashes on NULL values
The arguments 3 to 6 of the authorizer callback may be `NULL`[1], and
we have to properly deal with that.  Instead of causing a segfault, we
deny authorization, which is still better than a crash, and apparently,
we cannot do better anyway.

[1] <https://www.sqlite.org/c3ref/set_authorizer.html>

Closes GH-9040.
2022-07-27 12:49:16 +02:00
Christoph M. Becker
cf1664e91d
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9155: dba_open("non-existing", "c-", "flatfile") segfaults
2022-07-27 12:13:32 +02:00
Christoph M. Becker
a442e29485
Fix GH-9155: dba_open("non-existing", "c-", "flatfile") segfaults
We must not assume that the lock file has been opened.

Closes GH-9156.
2022-07-27 12:08:36 +02:00
Adam Saponara
8cf9c2f200
Fix GH-9090: Support assigning function pointers in FFI
Closes GH-9107.
2022-07-27 10:42:25 +02:00
Tim Düsterhus
d058acb4ac
Use ValueError if an invalid mode is passed to Mt19937 (#9159) 2022-07-27 09:03:02 +02:00
Christoph M. Becker
5d52d472ef
Fix #69181: READ_CSV|DROP_NEW_LINE drops newlines within fields
One may argue that `DROP_NEW_LINE` does not make sense in combination
with `READ_CSV`, but without `DROP_NEW_LINE`, `SKIP_EMPTY` does not
skip empty lines at all.  We could fix that, but do not for BC reasons.
Instead we no longer drop newlines in `spl_filesystem_file_read_ex()`
when reading CSV, but handle that in `spl_filesystem_file_read_csv()`
by treating lines with only (CR)LF as being empty as well.

Closes GH-7618.
2022-07-26 18:33:57 +02:00
David Carlier
9090e2602e sockets ext for solaris update.
socket filter support, system can support up to 32 filters giving the possibility to retrive the full list.
Closes #8191.
2022-07-25 19:28:25 +01:00
Christoph M. Becker
4834cfea1a
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9033: Loading blacklist file can fail due to negative length
2022-07-25 16:32:18 +02:00
Christoph M. Becker
35fd97c3c9
Fix GH-9033: Loading blacklist file can fail due to negative length
If the blacklist file contains a line with a single double-quote, we
called `zend_strndup(pbuf, -1)` what causes an unnecessary bail out;
instead we just ignore that line.

If the blacklist file contains an empty line, we may have caused an OOB
read; instead we just ignore that line.

Closes GH-9036.
2022-07-25 16:30:19 +02:00
Martin Herndl
229b189293
[ci skip] Fix str_split NEWS and UPGRADE note
Closes GH-9123.
2022-07-25 13:45:01 +02:00
Go Kudo
34b352d121
Fix memory leak on Randomizer::__construct() call twice (#9091)
When Radomizer::__construct() was called with no arguments, Randomizer\Engine\Secure was implicitly instantiate and memory was leaking.
Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2022-07-24 03:09:14 +09:00
George Peter Banyard
3c372901bd Add support to pass driver flags to DBA handlers
Currently only LMDB with DBA_LMDB_USE_SUB_DIR/DBA_LMDB_NO_SUB_DIR are supported
2022-07-23 18:38:27 +01:00
Tim Düsterhus
eff9aed159
[ci skip] Update NEWS for byte expansion in rand_rangeXX()
see GH-9083
see GH-9088
see GH-9056
2022-07-22 18:52:47 +02:00
Derick Rethans
1d0e5eddd5 Add test case for bug #80483/#75035 2022-07-22 15:34:57 +01:00
Derick Rethans
b1575f996c Merge branch 'PHP-8.1' 2022-07-22 13:08:11 +01:00
Derick Rethans
7831a1cae6 Add test case for GH-8964 2022-07-22 13:06:32 +01:00
Tim Düsterhus
c5f9b2f292
[ci skip] Fix version of NEWS entry
see 133b9b08da
2022-07-22 09:06:12 +02:00
Go Kudo
133b9b08da
Avoid signed integer overflow in php_random_range() (#9066) 2022-07-22 10:57:32 +09:00
Tim Düsterhus
dfbe96489d [ci skip] Add "segmentation fault if user engine throws" to NEWS
see GH-9055
2022-07-21 19:32:01 +02:00
George Peter Banyard
f60f6be66b
Update NEWS 2022-07-21 14:10:31 +01:00
George Peter Banyard
6cdfaf97e0
Update NEWS 2022-07-21 14:09:27 +01:00
George Peter Banyard
5b83b3a933
Fix memory leak in LMDB driver 2022-07-21 14:05:48 +01:00
Derick Rethans
1c8e566fb5 Update NEWS 2022-07-21 12:35:13 +01:00
Derick Rethans
3edf93d7ee Update NEWS 2022-07-21 12:34:45 +01:00
Christoph M. Becker
8487d8fa91
Fix GH-9067: random extension is not thread safe
For thread-safety, we need to initialize global variables in GINIT (or
RINIT), but not in MINIT.

Closes GH-9070.
2022-07-21 12:53:07 +02:00
Christoph M. Becker
c2bdaa48e1
Fix GH-9008: mb_detect_encoding(): wrong results with null $encodings
Passing `null` to `$encodings` is supposed to behave like passing the
result of `mb_detect_order()`.  Therefore, we need to remove the non-
encodings from the `elist` in this case as well.  Thus, we duplicate
the global `elist`, so we can modify it.

Closes GH-9063.
2022-07-20 16:58:55 +02:00
Christoph M. Becker
d430652935
Fix --CGI-- support of run-tests.php
The `--CGI--` section is supposed to be just a marker, and to be empty
as such.  However, a previous refactoring[1] broke that.

[1] <9140c9038a>

Closes GH-9061.
2022-07-20 14:41:28 +02:00
David CARLIER
1977ef92de opcache find best candidate near .text segment for large maps on FreeBSD.
Follow up on #8890 using similar workflow, we go through the php binary mapping per address boundaries.

Closes #8908.
2022-07-20 09:15:37 +01:00
Patrick Allaert
9af3327176
PHP-8.1 is now for PHP 8.1.10-dev 2022-07-20 06:48:52 +02:00
Pierrick Charron
8225e419e0
[ci skip] Update NEWS for PHP 8.2.0 beta2 2022-07-19 12:26:43 -04:00
Christoph M. Becker
32d55f7422
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-9017: php_stream_sock_open_from_socket could return NULL
2022-07-19 17:07:27 +02:00
Heiko Weber
3b7babf9b3
Fix GH-9017: php_stream_sock_open_from_socket could return NULL
Closes GH-9020.
2022-07-19 17:06:02 +02:00
Tim Düsterhus
7ae7df5b46
RFC: Make the iterator_*() family accept all iterables (#8819)
https://wiki.php.net/rfc/iterator_xyz_accept_array
2022-07-19 16:46:32 +02:00
David CARLIER
1416961505 opcache JIT support improvements attempts on macOs.
for cases when shared segments switch b/w R/W/X and R/X bits.

Closes #8382.
2022-07-19 13:41:33 +01:00
dixyes
745cf34ffc
Port standard/crc32 for windows arm64
We also add arm64 support for php_get_windows_cpu().

Closes GH-7703.
2022-07-19 13:23:44 +02:00
Go Kudo
4d8dd8d258
Implement Random Extension
https://wiki.php.net/rfc/rng_extension
https://wiki.php.net/rfc/random_extension_improvement
2022-07-19 10:27:38 +01:00
Gabriel Caruso
a670d2be74
Prepare for PHP 8.0.23 2022-07-19 10:31:08 +02:00
Eric Norris
09237f6126
Update request startup error messages 2022-07-18 23:19:59 +01:00
root
d8fc05c05e
Add FILTER_FLAG_GLOBAL_RANGE to filter Global IPs as per RFC 6890 2022-07-18 17:56:05 +01:00
Mikhail Galanin
ffdf25a270
Add "error_log_mode" setting 2022-07-18 15:41:28 +01:00
David CARLIER
9a8ae45c4b Revert "FPM: Downgrade occasional "failed to acquire scoreboard" warning"
This reverts commit 3040f75f43.
2022-07-18 14:21:54 +01:00
David CARLIER
2a5b2cca85 Revert "FPM: Downgrade occasional "failed to acquire scoreboard" warning"
This reverts commit 3040f75f43.
2022-07-18 14:21:07 +01:00
David Carlier
d0962859f4 Merge branch 'PHP-8.1' 2022-07-18 12:41:24 +01:00
David Carlier
edb173c200 Merge branch 'PHP-8.0' into PHP-8.1 2022-07-18 12:40:47 +01:00
Felix Wiedemann
3040f75f43 FPM: Downgrade occasional "failed to acquire scoreboard" warning
With request timeouts configured, php-fpm occasionally prints the
following warning:

   WARNING: failed to acquire scoreboard

This is happens when php-fpm checks the child scoreboards for timeouts,
but fails to acquire a lock immediately.  As this can (and does) occur
during normal operation, this commit downgrades this to a notice.
Closes #9019.
2022-07-18 12:40:16 +01:00
Arnaud Le Blanc
a6856760c2 [ci skip] NEWS 2022-07-18 12:36:54 +02:00
Arnaud Le Blanc
4b38779a48 [ci skip] NEWS 2022-07-18 12:35:24 +02:00
Jakub Zelenka
0a4a55fd44
Allow to not close stream on rscr dtor in php cli sapi 2022-07-18 10:58:50 +01:00
David Carlier
7e72c3dc8a [ci skip] NEWS typo 2022-07-15 14:53:42 +01:00
David CARLIER
c56e183226 opcache JIT: Adds initial support for macOs Instruments performance measurement.
By default, it is based on the perf_event Linux api, here
we add the proprietary Apple's format using directly its api.

Closes #8914.
2022-07-15 14:27:07 +01:00
David Carlier
7dcd8f854d Merge branch 'PHP-8.1' 2022-07-15 12:49:59 +01:00
David Carlier
f15cfba39b Merge branch 'PHP-8.0' into PHP-8.1 2022-07-15 12:48:09 +01:00
David CARLIER
d830a1f6f0 random extension macOs handling update.
Not such as fix but taking more precautions.
Indeed, the arc4random has two little flaws in this platform,
one already caught upfront by the extension (ie size 0), also
internal use of ccrng_generate which can silently fail in few rare
cases.

Closes #7824.
2022-07-15 12:43:43 +01:00
Cristian Rodríguez
3be9118662 random: whitelist arc4random_buf if glibc
Glibc will soon implement the BSD arc4random API. whitelist its
implementation as safe.

Closes #8984.
2022-07-15 12:33:05 +01:00
Arnaud Le Blanc
2673c1dfa1 [ci skip] NEWS 2022-07-15 13:21:39 +02:00
Arnaud Le Blanc
aadb24e817 Merge branch 'PHP-8.0' into PHP-8.1 2022-07-15 13:15:05 +02:00
Arnaud Le Blanc
20473374fa [ci skip] NEWS 2022-07-15 13:14:17 +02:00
David Carlier
37e214bdc2 Merge branch 'PHP-8.1' 2022-07-14 12:20:59 +01:00
David Carlier
b44a17c02a Merge branch 'PHP-8.0' into PHP-8.1 2022-07-14 12:13:21 +01:00
guoyiyuan
789a37f144 Prevent potential buffer overflow for large value of php_cli_server_workers_max
Fixes #8989.
Closes #9000.
2022-07-14 12:12:25 +01:00
Christoph M. Becker
56804e3221
Fix GH-8750: Can not create VT_ERROR variant type
We add support for creating `VT_ERROR` variants via `__construct()`,
and allow casting to int via `variant_cast()` and `variant_set_type()`.
We do not, however, allow type conversion by other means, to avoid
otherwise easily introduced type confusion.  VB(A) also only allows
explicit type conversion.

We also introduce `DISP_E_PARAMNOTFOUND` which might be the most
important `scode` for this purpose, since this allows to skip optional
parameters in method calls.

Closes GH-8886.
2022-07-12 16:43:14 +02:00
Christoph M. Becker
5365e1d5f1
[ci skip] Fix NEWS entry 2022-07-12 13:43:41 +02:00
Christoph M. Becker
5a459f6783
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8923: error_log on Windows can hold the file write lock
2022-07-12 13:38:35 +02:00
Christoph M. Becker
77e954afaa
Fix GH-8923: error_log on Windows can hold the file write lock
On Windows, closing a file which is locked may not immediately remove
the lock.  The `LockFileEx()` documentation states:

| Therefore, it is recommended that your process explicitly unlock all
| files it has locked when it terminates.

We comply, and also use the macro `LOCK_EX` instead of the magic number
`2`.

Closes GH-8925.
2022-07-12 13:36:20 +02:00
Christoph M. Becker
f22e0df033
[ci skip] Add missing NEWS entry
Cf. 32cceb75bf.
2022-07-12 12:00:08 +02:00
Christoph M. Becker
2fc9e769e8
Fix GH-8576: Bad interpretation of length when char is UTF-8
For columns of type `SQL_TEXT`, Firebird does not properly report the
actual column length, but rather only the maximum column length, so for
multi-byte encodings like UTF-8, such columns may have trailing
spaces.  We work around that by treating such columns as `SQL_VARYING`
when we ask the server to describe the colum, what yields the desired
results.

Given that this is a work-around, and may break code which expects the
results with trailing spaces, we target "master" only.

Closes GH-8926.
2022-07-12 11:57:25 +02:00
Mark Gallagher
327bb21986
FPM: Implement access log filtering
Adds a setting "access.suppress_path" to php-fpm pool configurations
which causes successful GET requests to the specified URIs to be
excluded from the access log. This is to reduce noise caused by
automated health checks.

Requests with response codes outwith the successful range 200 - 299,
requests made with query parameters and requests which have a
Content-Length other than 0 will ignore this setting as a security
precaution.

Closes GH-8174, #80428 [1]

[1] https://bugs.php.net/bug.php?id=80428
2022-07-10 23:21:14 +01:00
David Carlier
185d604d56 NEWS/UPGRADING changes 2022-07-10 21:30:08 +01:00
Arnaud Le Blanc
d217a669fc [ci skip] NEWS 2022-07-10 15:18:51 +02:00
Arnaud Le Blanc
d86141a891 [ci skip] NEWS 2022-07-09 23:00:52 +02:00