#
0d0375ab |
| 13-Mar-2024 |
Tim Düsterhus |
Merge branch 'PHP-8.2' into PHP-8.3 * PHP-8.2: random: Initialize the `mode` field when seeding in `php_random_default_status()` (#13690)
|
#
f34721ca |
| 13-Mar-2024 |
Tim Düsterhus |
random: Initialize the `mode` field when seeding in `php_random_default_status()` (#13690) This is not just an issue due to missing initialization since moving the state struct directly
random: Initialize the `mode` field when seeding in `php_random_default_status()` (#13690) This is not just an issue due to missing initialization since moving the state struct directly into the module globals. In earlier versions changing the mode to `MT_RAND_PHP` within a single request would also affect the mode for subsequent requests. Original commit message follows: This is a follow-up fix for GH-13579. The issue was detected in the nightly MSAN build. (cherry picked from commit bf0abd1629291c193064a9cb95a2da3565decc38)
show more ...
|
#
e6c0b09e |
| 29-Feb-2024 |
Tim Düsterhus |
Merge branch 'PHP-8.2' into PHP-8.3 * PHP-8.2: random: Fix unknown `mt_srand()` compatibility for unknown modes (#13544) Removed `REPORT_EXIT_STATUS=no` in libmysql tests R
Merge branch 'PHP-8.2' into PHP-8.3 * PHP-8.2: random: Fix unknown `mt_srand()` compatibility for unknown modes (#13544) Removed `REPORT_EXIT_STATUS=no` in libmysql tests Revert "Fix GH-13519: PGSQL_CONNECT_FORCE_RENEW with persistent connections." (#13546)
show more ...
|
#
e059498c |
| 29-Feb-2024 |
Tim Düsterhus |
random: Fix unknown `mt_srand()` compatibility for unknown modes (#13544) PHP 8.1 and below interpreted unknown modes as `MT_RAND_MT19937`, but PHP 8.2+ interprets them as `MT_RAND_PHP`.
random: Fix unknown `mt_srand()` compatibility for unknown modes (#13544) PHP 8.1 and below interpreted unknown modes as `MT_RAND_MT19937`, but PHP 8.2+ interprets them as `MT_RAND_PHP`. Align the behavior with PHP 8.1 and below, because folks should be steered towards the standard mode.
show more ...
|
#
61251093 |
| 07-Jul-2023 |
Tim Düsterhus |
Deprecate MT_RAND_PHP (#11560) see https://wiki.php.net/rfc/deprecations_php_8_3#mt_rand_php |
#
b14dd85d |
| 23-Feb-2023 |
Tim Düsterhus |
random: Move the CSPRNG implementation into a separate C file (#10668) The CSPRNG is a delicate and security relevant piece of code and having it in the giant random.c makes it much hard
random: Move the CSPRNG implementation into a separate C file (#10668) The CSPRNG is a delicate and security relevant piece of code and having it in the giant random.c makes it much harder to verify changes to it. Split it into a separate file.
show more ...
|
#
6c8ef1d9 |
| 25-Jan-2023 |
Tim Düsterhus |
random: Reduce variable scopes in CSPRNG (#10426) * random: Convert the urandom loop into a while() loop This allows us to more easily reduce the scope of `n` in a future commit and
random: Reduce variable scopes in CSPRNG (#10426) * random: Convert the urandom loop into a while() loop This allows us to more easily reduce the scope of `n` in a future commit and now matches the getrandom(2) loop. * random: Move the errno reset immediately above the getrandom(2) call * random: Reduce the scope of `n` in the CSPRNG * random: Declare `n` outside of preprocessor branch
show more ...
|
#
2740920a |
| 23-Jan-2023 |
David Carlier |
random disable arc4random_buf for glibc, merge mistake |
#
948cb470 |
| 15-Jan-2023 |
David Carlier |
random netbsd 10 update finally supporting getrandom syscall properly. Close GH-10327. |
#
a7998fda |
| 23-Jan-2023 |
Tim Düsterhus |
random: Simplify control flow for handling /dev/urandom errors (#10392) The only way the previous `if (read_bytes < size)` branch could be taken is when the loop was exited by the `break
random: Simplify control flow for handling /dev/urandom errors (#10392) The only way the previous `if (read_bytes < size)` branch could be taken is when the loop was exited by the `break;` statement. We can just merge this into the loop to make the code more obvious.
show more ...
|
#
56dc2eb3 |
| 23-Jan-2023 |
Tim Düsterhus |
Merge branch 'PHP-8.2' * PHP-8.2: random: Do not trust arc4random_buf() on glibc (#10390)
|
#
57b362b7 |
| 23-Jan-2023 |
Tim Düsterhus |
random: Do not trust arc4random_buf() on glibc (#10390) This effectively reverts #8984. As discussed in #10327 which will enable the use of the getrandom(2) syscall on NetBSD in
random: Do not trust arc4random_buf() on glibc (#10390) This effectively reverts #8984. As discussed in #10327 which will enable the use of the getrandom(2) syscall on NetBSD instead of relying on the userland arc4random_buf(), the CSPRNG should prioritize security over speed [1] and history has shown that userland implementations unavoidably fall short on the security side. In fact the glibc implementation is a thin wrapper around the syscall due to security concerns and thus does not provide any benefit over just calling getrandom(2) ourselves. Even without any performance optimizations the CSPRNG should be plenty fast for the vast majority of applications, because they often only need a few bytes of randomness to generate a session ID. If speed is desired, the OO API offers faster, but non-cryptographically secure engines.
show more ...
|
#
2b395f7b |
| 20-Jan-2023 |
Tim Düsterhus |
random: Remove check for HAVE_DEV_URANDOM It cannot be decided whether the device is available at build time, PHP might run in a container or chroot that does not expose the device. Simp
random: Remove check for HAVE_DEV_URANDOM It cannot be decided whether the device is available at build time, PHP might run in a container or chroot that does not expose the device. Simply attempt to open it, if it does not exist it will fail. This improves readability of php_random_bytes() by removing one layer of preprocessor conditions.
show more ...
|
#
1f05d6ef |
| 20-Jan-2023 |
Máté Kocsis |
Fix GH-10292 make the default value of the first parame of srand() and mt_srand() nullable (#10380) Co-authored-by: Tim Düsterhus <timwolla@googlemail.com> |
#
c8955c07 |
| 16-Jan-2023 |
Christoph M. Becker |
Revert GH-10220 Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>. This reverts commit ecc880f491d66081298a16634629f149459706a9. This reverts commit 588a07
Revert GH-10220 Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>. This reverts commit ecc880f491d66081298a16634629f149459706a9. This reverts commit 588a07f7371ee2b5fac17de147926780e427fae6. This reverts commit f377e15751d3aa48b69cd9bcc366ede7803d511f. This reverts commit b4ba16fe189b109144aff669e11d81365160104b. This reverts commit 694ec1deea36e366b28b6349a52be49824e1a1a8. This reverts commit 6b34de8eba9f66882ae16e6073af28783670ac53. This reverts commit aa1cd02a4367834026ea2205ea13a2f904455aa1. This reverts commit 308fd311ea6fcf3094b448df7f2b264f08e4fe4f. This reverts commit 16203b53e1822a37b6ba6f2ab198bb435d05fdad. This reverts commit 738fb5ca5412f5e833a7fab82b11519e635a3357. This reverts commit 9fdbefacd3c382d731aa175b7bdc002ec9cb2b30. This reverts commit cd4a7c1d90562ebb5f89caf94d00d579631b9fbe. This reverts commit 928685eba2b2f0ded90e7f78fd806ea164002f6e. This reverts commit 01e5ffc85cd4357fd7b5b7ceefa29f2d10ca26b7.
show more ...
|
#
e7c0f4e8 |
| 10-Jan-2023 |
Tim Düsterhus |
random: Rely on `free(NULL)` being safe for random status freeing (#10246) * random: Rely on `free(NULL)` being safe for random status freeing * random: Restructure `php_random_stat
random: Rely on `free(NULL)` being safe for random status freeing (#10246) * random: Rely on `free(NULL)` being safe for random status freeing * random: Restructure `php_random_status_free()` to not early-return
show more ...
|
#
308fd311 |
| 04-Jan-2023 |
Max Kellermann |
ext/{standard,json,random,...}: add missing includes |
#
5f42a464 |
| 07-Jan-2023 |
Tim Düsterhus |
Merge branch 'PHP-8.2' * PHP-8.2: random: Fix check before closing `random_fd` (#10247)
|
#
32f503e4 |
| 07-Jan-2023 |
Tim Düsterhus |
random: Fix check before closing `random_fd` (#10247) If, for whatever reason, the random_fd has been assigned file descriptor `0` it previously failed to close during module shutdown, t
random: Fix check before closing `random_fd` (#10247) If, for whatever reason, the random_fd has been assigned file descriptor `0` it previously failed to close during module shutdown, thus leaking the descriptor.
show more ...
|
#
f9a1a903 |
| 14-Dec-2022 |
Tim Düsterhus |
Add Randomizer::nextFloat() and Randomizer::getFloat() (#9679) * random: Add Randomizer::nextFloat() * random: Check that doubles are IEEE-754 in Randomizer::nextFloat() *
Add Randomizer::nextFloat() and Randomizer::getFloat() (#9679) * random: Add Randomizer::nextFloat() * random: Check that doubles are IEEE-754 in Randomizer::nextFloat() * random: Add Randomizer::nextFloat() tests * random: Add Randomizer::getFloat() implementing the y-section algorithm The algorithm is published in: Drawing Random Floating-Point Numbers from an Interval. Frédéric Goualard, ACM Trans. Model. Comput. Simul., 32:3, 2022. https://doi.org/10.1145/3503512 * random: Implement getFloat_gamma() optimization see https://github.com/php/php-src/pull/9679/files#r994668327 * random: Add Random\IntervalBoundary * random: Split the implementation of γ-section into its own file * random: Add tests for Randomizer::getFloat() * random: Fix γ-section for 32-bit systems * random: Replace check for __STDC_IEC_559__ by compile-time check for DBL_MANT_DIG * random: Drop nextFloat_spacing.phpt * random: Optimize Randomizer::getFloat() implementation * random: Reject non-finite parameters in Randomizer::getFloat() * random: Add NEWS/UPGRADING for Randomizer’s float functionality
show more ...
|
#
ac3ecd03 |
| 09-Dec-2022 |
Joshua Rüsweg |
Add `Randomizer::getBytesFromString()` method (#9664) * Add `Randomizer::getBytesFromAlphabet()` method * Rename `getBytesFromAlphabet` to `getBytesFromString` * [ci skip]
Add `Randomizer::getBytesFromString()` method (#9664) * Add `Randomizer::getBytesFromAlphabet()` method * Rename `getBytesFromAlphabet` to `getBytesFromString` * [ci skip] Add NEWS/UPGRADING for Randomizer::getBytesFromString() Co-authored-by: Tim Düsterhus <tim@bastelstu.be>
show more ...
|
#
5989953e |
| 28-Oct-2022 |
Tim Düsterhus |
Merge branch 'PHP-8.2' * PHP-8.2: Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839)
|
#
7f0b228f |
| 28-Oct-2022 |
Tim Düsterhus |
Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839) * Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP As some left-over comments in
Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP (#9839) * Fix pre-PHP 8.2 compatibility for php_mt_rand_range() with MT_RAND_PHP As some left-over comments indicated: > Legacy mode deliberately not inside php_mt_rand_range() > to prevent other functions being affected The broken scaler was only used for `php_mt_rand_common()`, not `php_mt_rand_range()`. The former is only used for `mt_rand()`, whereas the latter is used for `array_rand()` and others. With the refactoring for the introduction of ext/random `php_mt_rand_common()` and `php_mt_rand_range()` were accidentally unified, thus introducing a behavioral change that was reported in FakerPHP/Faker#528. This commit moves the checks for `MT_RAND_PHP` from the general-purpose `range()` function back into `php_mt_rand_common()` and also into `Randomizer::getInt()` for drop-in compatibility with `mt_rand()`. * [ci skip] NEWS for `MT_RAND_PHP` compatibility
show more ...
|
#
32d101b1 |
| 06-Oct-2022 |
Tim Düsterhus |
Merge branch 'PHP-8.2' * PHP-8.2: Reduce scope of `r` in rand_rangeXX (#9678)
|
#
59a19d71 |
| 06-Oct-2022 |
Tim Düsterhus |
Reduce scope of `r` in rand_rangeXX (#9678) This variable is only accessed within a single iteration of the expansion loop. |