diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/random_compat/random_bytes_dev_urandom.php --- a/wp/wp-includes/random_compat/random_bytes_dev_urandom.php Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-includes/random_compat/random_bytes_dev_urandom.php Tue Sep 27 16:37:53 2022 +0200 @@ -1,22 +1,22 @@ $st */ + $st = fstat($fp); + if (($st['mode'] & 0170000) !== 020000) { + fclose($fp); + $fp = false; + } } } - if (!empty($fp)) { + if (is_resource($fp)) { /** * stream_set_read_buffer() does not exist in HHVM * @@ -83,6 +106,7 @@ } try { + /** @var int $bytes */ $bytes = RandomCompat_intval($bytes); } catch (TypeError $ex) { throw new TypeError( @@ -103,7 +127,7 @@ * if (empty($fp)) line is logic that should only be run once per * page load. */ - if (!empty($fp)) { + if (is_resource($fp)) { /** * @var int */ @@ -123,29 +147,28 @@ */ $read = fread($fp, $remaining); if (!is_string($read)) { - 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; - } + /** + * We cannot safely read from the file. Exit the + * do-while loop and trigger the exception condition + * + * @var string|bool + */ + $buf = false; + break; } /** * Decrease the number of bytes returned from remaining */ $remaining -= RandomCompat_strlen($read); /** - * @var string|bool + * @var string $buf */ - $buf = $buf . $read; + $buf .= $read; } while ($remaining > 0); /** * Is our result valid? + * @var string|bool $buf */ if (is_string($buf)) { if (RandomCompat_strlen($buf) === $bytes) {