X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/138998bbd8f7a1ac38b2f1eacbdf7cd522be4b13..8d3bb1a5dcfdea9857d3c88c3751f09593e34dc8:/wp-includes/random_compat/random_bytes_mcrypt.php diff --git a/wp-includes/random_compat/random_bytes_mcrypt.php b/wp-includes/random_compat/random_bytes_mcrypt.php index 5a1b688f..7ac9d910 100644 --- a/wp-includes/random_compat/random_bytes_mcrypt.php +++ b/wp-includes/random_compat/random_bytes_mcrypt.php @@ -48,6 +48,7 @@ function random_bytes($bytes) 'random_bytes(): $bytes must be an integer' ); } + if ($bytes < 1) { throw new Error( 'Length must be greater than 0' @@ -55,14 +56,17 @@ function random_bytes($bytes) } $buf = @mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM); - if ($buf !== false) { - if (RandomCompat_strlen($buf) === $bytes) { - /** - * Return our random entropy buffer here: - */ - return $buf; - } + if ( + $buf !== false + && + RandomCompat_strlen($buf) === $bytes + ) { + /** + * Return our random entropy buffer here: + */ + return $buf; } + /** * If we reach here, PHP has failed us. */