<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[52742] trunk/src/wp-includes/random_compat: External Libraries: Update random_compat to version 2.0.21.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/52742">52742</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/52742","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-02-16 21:17:04 +0000 (Wed, 16 Feb 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>External Libraries: Update random_compat to version 2.0.21.
The latest release includes improved compatibility with PHP 8.1, as well as some bug fixes for Windows platforms.
Release notes:
https://github.com/paragonie/random_compat/releases/tag/v2.0.21
For a full list of changes in this update, see the random_compat GitHub:
https://github.com/paragonie/random_compat/compare/v2.0.11...v2.0.21
Follow-up to <a href="https://core.trac.wordpress.org/changeset/42130">[42130]</a>.
Props jrf, paragoninitiativeenterprises.
Fixes <a href="https://core.trac.wordpress.org/ticket/55181">#55181</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrandom_compatbyte_safe_stringsphp">trunk/src/wp-includes/random_compat/byte_safe_strings.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatcast_to_intphp">trunk/src/wp-includes/random_compat/cast_to_int.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compaterror_polyfillphp">trunk/src/wp-includes/random_compat/error_polyfill.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatrandomphp">trunk/src/wp-includes/random_compat/random.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatrandom_bytes_com_dotnetphp">trunk/src/wp-includes/random_compat/random_bytes_com_dotnet.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatrandom_bytes_dev_urandomphp">trunk/src/wp-includes/random_compat/random_bytes_dev_urandom.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatrandom_bytes_libsodiumphp">trunk/src/wp-includes/random_compat/random_bytes_libsodium.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatrandom_bytes_libsodium_legacyphp">trunk/src/wp-includes/random_compat/random_bytes_libsodium_legacy.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatrandom_bytes_mcryptphp">trunk/src/wp-includes/random_compat/random_bytes_mcrypt.php</a></li>
<li><a href="#trunksrcwpincludesrandom_compatrandom_intphp">trunk/src/wp-includes/random_compat/random_int.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrandom_compatbyte_safe_stringsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/byte_safe_strings.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/byte_safe_strings.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/byte_safe_strings.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,7 +5,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -28,8 +28,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (!is_callable('RandomCompat_strlen')) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- defined('MB_OVERLOAD_STRING') &&
- ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ defined('MB_OVERLOAD_STRING')
+ &&
+ ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * strlen() implementation that isn't brittle to mbstring.func_overload
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -82,8 +83,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> defined('MB_OVERLOAD_STRING')
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- &&
- ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ &&
+ ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * substr() implementation that isn't brittle to mbstring.func_overload
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,7 +94,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $binary_string
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $start
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $length (optional)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|null $length (optional)
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws TypeError
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,6 +119,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * mb_substr($str, 0, NULL, '8bit') returns an empty string on
</span><span class="cx" style="display: block; padding: 0 10px"> * PHP 5.3, so we have to find the length ourselves.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $length */
</ins><span class="cx" style="display: block; padding: 0 10px"> $length = RandomCompat_strlen($binary_string) - $start;
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif (!is_int($length)) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -133,7 +135,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return '';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (string) mb_substr($binary_string, $start, $length, '8bit');
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (string) mb_substr(
+ (string) $binary_string,
+ (int) $start,
+ (int) $length,
+ '8bit'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,7 +152,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $binary_string
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $start
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param int $length (optional)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int|null $length (optional)
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @throws TypeError
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -172,10 +179,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (string) substr($binary_string, $start, $length);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (string) substr(
+ (string )$binary_string,
+ (int) $start,
+ (int) $length
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return (string) substr($binary_string, $start);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (string) substr(
+ (string) $binary_string,
+ (int) $start
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compatcast_to_intphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/cast_to_int.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/cast_to_int.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/cast_to_int.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,7 +5,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -27,19 +27,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (!is_callable('RandomCompat_intval')) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Cast to an integer if we can, safely.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
</span><span class="cx" style="display: block; padding: 0 10px"> * (non-inclusive), it will sanely cast it to an int. If you it's equal to
</span><span class="cx" style="display: block; padding: 0 10px"> * ~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
</span><span class="cx" style="display: block; padding: 0 10px"> * lose precision, so the <= and => operators might accidentally let a float
</span><span class="cx" style="display: block; padding: 0 10px"> * through.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param int|float $number The number we want to convert to an int
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $fail_open Set to true to not throw an exception
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return float|int
</span><span class="cx" style="display: block; padding: 0 10px"> * @psalm-suppress InvalidReturnType
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,14 +50,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (is_int($number) || is_float($number)) {
</span><span class="cx" style="display: block; padding: 0 10px"> $number += 0;
</span><span class="cx" style="display: block; padding: 0 10px"> } elseif (is_numeric($number)) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @psalm-suppress InvalidOperand */
</ins><span class="cx" style="display: block; padding: 0 10px"> $number += 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int|float $number */
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> is_float($number)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- &&
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ &&
</ins><span class="cx" style="display: block; padding: 0 10px"> $number > ~PHP_INT_MAX
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- &&
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ &&
</ins><span class="cx" style="display: block; padding: 0 10px"> $number < PHP_INT_MAX
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $number = (int) $number;
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compaterror_polyfillphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/error_polyfill.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/error_polyfill.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/error_polyfill.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,12 +1,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Random_* Compatibility Library
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Random_* Compatibility Library
</ins><span class="cx" style="display: block; padding: 0 10px"> * for using the new PHP 7 random_* API in PHP 5 projects
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="cx" style="display: block; padding: 0 10px"> * in the Software without restriction, including without limitation the rights
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -30,7 +30,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // We can't really avoid making this extend Exception in PHP 5.
</span><span class="cx" style="display: block; padding: 0 10px"> class Error extends Exception
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -38,12 +38,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (is_subclass_of('Error', 'Exception')) {
</span><span class="cx" style="display: block; padding: 0 10px"> class TypeError extends Error
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> class TypeError extends Exception
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compatrandomphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/random.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/random.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/random.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3,12 +3,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Random_* Compatibility Library
</span><span class="cx" style="display: block; padding: 0 10px"> * for using the new PHP 7 random_* API in PHP 5 projects
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @version 2.0.10
- * @released 2017-03-13
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @version 2.0.17
+ * @released 2018-07-04
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -54,9 +54,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $RandomCompatDIR = dirname(__FILE__);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-require_once $RandomCompatDIR . '/byte_safe_strings.php';
-require_once $RandomCompatDIR . '/cast_to_int.php';
-require_once $RandomCompatDIR . '/error_polyfill.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'byte_safe_strings.php';
+require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'cast_to_int.php';
+require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'error_polyfill.php';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (!is_callable('random_bytes')) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,9 +76,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (extension_loaded('libsodium')) {
</span><span class="cx" style="display: block; padding: 0 10px"> // See random_bytes_libsodium.php
</span><span class="cx" style="display: block; padding: 0 10px"> if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- require_once $RandomCompatDIR . '/random_bytes_libsodium.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> } elseif (method_exists('Sodium', 'randombytes_buf')) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- require_once $RandomCompatDIR . '/random_bytes_libsodium_legacy.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium_legacy.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -117,7 +117,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // place, that is not helpful to us here.
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // See random_bytes_dev_urandom.php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- require_once $RandomCompatDIR . '/random_bytes_dev_urandom.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_dev_urandom.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> // Unset variables after use
</span><span class="cx" style="display: block; padding: 0 10px"> $RandomCompat_basedir = null;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -159,7 +159,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> extension_loaded('mcrypt')
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // See random_bytes_mcrypt.php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- require_once $RandomCompatDIR . '/random_bytes_mcrypt.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_mcrypt.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $RandomCompatUrandom = null;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -182,9 +182,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if (!in_array('com', $RandomCompat_disabled_classes)) {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1');
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (method_exists($RandomCompatCOMtest, 'GetRandom')) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @psalm-suppress TypeDoesNotContainType */
+ if (is_callable(array($RandomCompatCOMtest, 'GetRandom'))) {
</ins><span class="cx" style="display: block; padding: 0 10px"> // See random_bytes_com_dotnet.php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- require_once $RandomCompatDIR . '/random_bytes_com_dotnet.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (com_exception $e) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Don't try to use it.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -203,8 +204,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * and hope the developer won't let it fail silently.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param mixed $length
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return void
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @psalm-suppress InvalidReturnType
</ins><span class="cx" style="display: block; padding: 0 10px"> * @throws Exception
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function random_bytes($length)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -212,12 +214,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> throw new Exception(
</span><span class="cx" style="display: block; padding: 0 10px"> 'There is no suitable CSPRNG installed on your system'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return '';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (!is_callable('random_int')) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- require_once $RandomCompatDIR . '/random_int.php';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_int.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $RandomCompatDIR = null;
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compatrandom_bytes_com_dotnetphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/random_bytes_com_dotnet.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/random_bytes_com_dotnet.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/random_bytes_com_dotnet.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,12 +1,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Random_* Compatibility Library
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Random_* Compatibility Library
</ins><span class="cx" style="display: block; padding: 0 10px"> * for using the new PHP 7 random_* API in PHP 5 projects
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="cx" style="display: block; padding: 0 10px"> * in the Software without restriction, including without limitation the rights
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,10 +13,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span><span class="cx" style="display: block; padding: 0 10px"> * copies of the Software, and to permit persons to whom the Software is
</span><span class="cx" style="display: block; padding: 0 10px"> * furnished to do so, subject to the following conditions:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The above copyright notice and this permission notice shall be included in
</span><span class="cx" style="display: block; padding: 0 10px"> * all copies or substantial portions of the Software.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx" style="display: block; padding: 0 10px"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx" style="display: block; padding: 0 10px"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -41,6 +41,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function random_bytes($bytes)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $bytes */
</ins><span class="cx" style="display: block; padding: 0 10px"> $bytes = RandomCompat_intval($bytes);
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (TypeError $ex) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -54,6 +55,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var string $buf */
</ins><span class="cx" style="display: block; padding: 0 10px"> $buf = '';
</span><span class="cx" style="display: block; padding: 0 10px"> if (!class_exists('COM')) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new Error(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,6 +62,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'COM does not exist'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var COM $util */
</ins><span class="cx" style="display: block; padding: 0 10px"> $util = new COM('CAPICOM.Utilities.1');
</span><span class="cx" style="display: block; padding: 0 10px"> $execCount = 0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -68,12 +71,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * get N bytes of random data, then CAPICOM has failed us.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> do {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $buf .= base64_decode($util->GetRandom($bytes, 0));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $buf .= base64_decode((string) $util->GetRandom($bytes, 0));
</ins><span class="cx" style="display: block; padding: 0 10px"> if (RandomCompat_strlen($buf) >= $bytes) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Return our random entropy buffer here:
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return RandomCompat_substr($buf, 0, $bytes);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return (string) RandomCompat_substr($buf, 0, $bytes);
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ++$execCount;
</span><span class="cx" style="display: block; padding: 0 10px"> } while ($execCount < $bytes);
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -85,4 +88,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'Could not gather sufficient random data'
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
</del><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of file
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+}
</ins></span></pre></div>
<a id="trunksrcwpincludesrandom_compatrandom_bytes_dev_urandomphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/random_bytes_dev_urandom.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/random_bytes_dev_urandom.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/random_bytes_dev_urandom.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,12 +1,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Random_* Compatibility Library
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Random_* Compatibility Library
</ins><span class="cx" style="display: block; padding: 0 10px"> * for using the new PHP 7 random_* API in PHP 5 projects
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="cx" style="display: block; padding: 0 10px"> * in the Software without restriction, including without limitation the rights
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,10 +13,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span><span class="cx" style="display: block; padding: 0 10px"> * copies of the Software, and to permit persons to whom the Software is
</span><span class="cx" style="display: block; padding: 0 10px"> * furnished to do so, subject to the following conditions:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The above copyright notice and this permission notice shall be included in
</span><span class="cx" style="display: block; padding: 0 10px"> * all copies or substantial portions of the Software.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx" style="display: block; padding: 0 10px"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx" style="display: block; padding: 0 10px"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,6 +36,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * random numbers in accordance with best practices
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Why we use /dev/urandom and not /dev/random
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @ref https://www.2uo.de/myths-about-urandom
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ref http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $bytes
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,25 +47,47 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function random_bytes($bytes)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var resource $fp */
</ins><span class="cx" style="display: block; padding: 0 10px"> static $fp = null;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * This block should only be run once
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if (empty($fp)) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * We use /dev/urandom if it is a char device.
- * We never fall back to /dev/random
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * We don't want to ever read C:\dev\random, only /dev/urandom on
+ * Unix-like operating systems. While we guard against this
+ * condition in random.php, it doesn't hurt to be defensive in depth
+ * here.
+ *
+ * To that end, we only try to open /dev/urandom if we're on a Unix-
+ * like operating system (which means the directory separator is set
+ * to "/" not "\".
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fp = fopen('/dev/urandom', 'rb');
- if (!empty($fp)) {
- $st = fstat($fp);
- if (($st['mode'] & 0170000) !== 020000) {
- fclose($fp);
- $fp = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (DIRECTORY_SEPARATOR === '/') {
+ if (!is_readable('/dev/urandom')) {
+ throw new Exception(
+ 'Environment misconfiguration: ' .
+ '/dev/urandom cannot be read.'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * We use /dev/urandom if it is a char device.
+ * We never fall back to /dev/random
+ */
+ /** @var resource|bool $fp */
+ $fp = fopen('/dev/urandom', 'rb');
+ if (is_resource($fp)) {
+ /** @var array<string, int> $st */
+ $st = fstat($fp);
+ if (($st['mode'] & 0170000) !== 020000) {
+ fclose($fp);
+ $fp = false;
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!empty($fp)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_resource($fp)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * stream_set_read_buffer() does not exist in HHVM
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -83,6 +106,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $bytes */
</ins><span class="cx" style="display: block; padding: 0 10px"> $bytes = RandomCompat_intval($bytes);
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (TypeError $ex) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -103,7 +127,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * if (empty($fp)) line is logic that should only be run once per
</span><span class="cx" style="display: block; padding: 0 10px"> * page load.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (!empty($fp)) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_resource($fp)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @var int
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,16 +147,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $read = fread($fp, $remaining);
</span><span class="cx" style="display: block; padding: 0 10px"> if (!is_string($read)) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($read === false) {
- /**
- * We cannot safely read from the file. Exit the
- * do-while loop and trigger the exception condition
- *
- * @var string|bool
- */
- $buf = false;
- break;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * We cannot safely read from the file. Exit the
+ * do-while loop and trigger the exception condition
+ *
+ * @var string|bool
+ */
+ $buf = false;
+ break;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Decrease the number of bytes returned from remaining
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -139,13 +161,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $remaining -= RandomCompat_strlen($read);
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @var string|bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string $buf
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $buf = $buf . $read;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $buf .= $read;
</ins><span class="cx" style="display: block; padding: 0 10px"> } while ($remaining > 0);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Is our result valid?
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @var string|bool $buf
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if (is_string($buf)) {
</span><span class="cx" style="display: block; padding: 0 10px"> if (RandomCompat_strlen($buf) === $bytes) {
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compatrandom_bytes_libsodiumphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/random_bytes_libsodium.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/random_bytes_libsodium.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/random_bytes_libsodium.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,12 +1,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Random_* Compatibility Library
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Random_* Compatibility Library
</ins><span class="cx" style="display: block; padding: 0 10px"> * for using the new PHP 7 random_* API in PHP 5 projects
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="cx" style="display: block; padding: 0 10px"> * in the Software without restriction, including without limitation the rights
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,10 +13,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span><span class="cx" style="display: block; padding: 0 10px"> * copies of the Software, and to permit persons to whom the Software is
</span><span class="cx" style="display: block; padding: 0 10px"> * furnished to do so, subject to the following conditions:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The above copyright notice and this permission notice shall be included in
</span><span class="cx" style="display: block; padding: 0 10px"> * all copies or substantial portions of the Software.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx" style="display: block; padding: 0 10px"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx" style="display: block; padding: 0 10px"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,6 +43,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function random_bytes($bytes)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $bytes */
</ins><span class="cx" style="display: block; padding: 0 10px"> $bytes = RandomCompat_intval($bytes);
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (TypeError $ex) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,6 +61,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * \Sodium\randombytes_buf() doesn't allow more than 2147483647 bytes to be
</span><span class="cx" style="display: block; padding: 0 10px"> * generated in one invocation.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var string|bool $buf */
</ins><span class="cx" style="display: block; padding: 0 10px"> if ($bytes > 2147483647) {
</span><span class="cx" style="display: block; padding: 0 10px"> $buf = '';
</span><span class="cx" style="display: block; padding: 0 10px"> for ($i = 0; $i < $bytes; $i += 1073741824) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,10 +71,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $buf .= \Sodium\randombytes_buf($n);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var string|bool $buf */
</ins><span class="cx" style="display: block; padding: 0 10px"> $buf = \Sodium\randombytes_buf($bytes);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($buf !== false) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (is_string($buf)) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if (RandomCompat_strlen($buf) === $bytes) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $buf;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compatrandom_bytes_libsodium_legacyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/random_bytes_libsodium_legacy.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/random_bytes_libsodium_legacy.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/random_bytes_libsodium_legacy.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,12 +1,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Random_* Compatibility Library
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Random_* Compatibility Library
</ins><span class="cx" style="display: block; padding: 0 10px"> * for using the new PHP 7 random_* API in PHP 5 projects
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="cx" style="display: block; padding: 0 10px"> * in the Software without restriction, including without limitation the rights
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,10 +13,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span><span class="cx" style="display: block; padding: 0 10px"> * copies of the Software, and to permit persons to whom the Software is
</span><span class="cx" style="display: block; padding: 0 10px"> * furnished to do so, subject to the following conditions:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The above copyright notice and this permission notice shall be included in
</span><span class="cx" style="display: block; padding: 0 10px"> * all copies or substantial portions of the Software.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx" style="display: block; padding: 0 10px"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx" style="display: block; padding: 0 10px"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,6 +43,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function random_bytes($bytes)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $bytes */
</ins><span class="cx" style="display: block; padding: 0 10px"> $bytes = RandomCompat_intval($bytes);
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (TypeError $ex) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compatrandom_bytes_mcryptphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/random_bytes_mcrypt.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/random_bytes_mcrypt.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/random_bytes_mcrypt.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,12 +1,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Random_* Compatibility Library
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Random_* Compatibility Library
</ins><span class="cx" style="display: block; padding: 0 10px"> * for using the new PHP 7 random_* API in PHP 5 projects
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="cx" style="display: block; padding: 0 10px"> * in the Software without restriction, including without limitation the rights
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -13,10 +13,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
</span><span class="cx" style="display: block; padding: 0 10px"> * copies of the Software, and to permit persons to whom the Software is
</span><span class="cx" style="display: block; padding: 0 10px"> * furnished to do so, subject to the following conditions:
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * The above copyright notice and this permission notice shall be included in
</span><span class="cx" style="display: block; padding: 0 10px"> * all copies or substantial portions of the Software.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
</span><span class="cx" style="display: block; padding: 0 10px"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
</span><span class="cx" style="display: block; padding: 0 10px"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,6 +42,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function random_bytes($bytes)
</span><span class="cx" style="display: block; padding: 0 10px"> {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $bytes */
</ins><span class="cx" style="display: block; padding: 0 10px"> $bytes = RandomCompat_intval($bytes);
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (TypeError $ex) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -55,10 +56,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var string|bool $buf */
+ $buf = @mcrypt_create_iv((int) $bytes, (int) MCRYPT_DEV_URANDOM);
</ins><span class="cx" style="display: block; padding: 0 10px"> if (
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $buf !== false
- &&
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ is_string($buf)
+ &&
</ins><span class="cx" style="display: block; padding: 0 10px"> RandomCompat_strlen($buf) === $bytes
</span><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrandom_compatrandom_intphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/random_compat/random_int.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/random_compat/random_int.php 2022-02-16 17:26:46 UTC (rev 52741)
+++ trunk/src/wp-includes/random_compat/random_int.php 2022-02-16 21:17:04 UTC (rev 52742)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,7 +7,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * The MIT License (MIT)
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copyright (c) 2015 - 2017 Paragon Initiative Enterprises
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copyright (c) 2015 - 2018 Paragon Initiative Enterprises
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Permission is hereby granted, free of charge, to any person obtaining a copy
</span><span class="cx" style="display: block; padding: 0 10px"> * of this software and associated documentation files (the "Software"), to deal
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -51,6 +51,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $min */
</ins><span class="cx" style="display: block; padding: 0 10px"> $min = RandomCompat_intval($min);
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (TypeError $ex) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,6 +60,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $max */
</ins><span class="cx" style="display: block; padding: 0 10px"> $max = RandomCompat_intval($max);
</span><span class="cx" style="display: block; padding: 0 10px"> } catch (TypeError $ex) {
</span><span class="cx" style="display: block; padding: 0 10px"> throw new TypeError(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -90,11 +92,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * so we can minimize the number of discards
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $attempts = $bits = $bytes = $mask = $valueShift = 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $attempts */
+ /** @var int $bits */
+ /** @var int $bytes */
+ /** @var int $mask */
+ /** @var int $valueShift */
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * At this point, $range is a positive number greater than 0. It might
</span><span class="cx" style="display: block; padding: 0 10px"> * overflow, however, if $max - $min > PHP_INT_MAX. PHP will cast it to
</span><span class="cx" style="display: block; padding: 0 10px"> * a float and we will lose some precision.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @var int|float $range
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $range = $max - $min;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -115,6 +124,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ref http://3v4l.org/XX9r5 (64-bit)
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $bytes = PHP_INT_SIZE;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $mask */
</ins><span class="cx" style="display: block; padding: 0 10px"> $mask = ~0;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,16 +139,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> ++$bits;
</span><span class="cx" style="display: block; padding: 0 10px"> $range >>= 1;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $mask */
</ins><span class="cx" style="display: block; padding: 0 10px"> $mask = $mask << 1 | 1;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $valueShift = $min;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $val */
</ins><span class="cx" style="display: block; padding: 0 10px"> $val = 0;
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Now that we have our parameters set up, let's begin generating
</span><span class="cx" style="display: block; padding: 0 10px"> * random integers until one falls between $min and $max
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @psalm-suppress RedundantCondition */
</ins><span class="cx" style="display: block; padding: 0 10px"> do {
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * The rejection probability is at most 0.5, so this corresponds
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -169,6 +182,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> for ($i = 0; $i < $bytes; ++$i) {
</span><span class="cx" style="display: block; padding: 0 10px"> $val |= ord($randomByteString[$i]) << ($i * 8);
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /** @var int $val */
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Apply mask
</span></span></pre>
</div>
</div>
</body>
</html>