X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..refs/tags/wordpress-4.5:/wp-includes/random_compat/random_bytes_com_dotnet.php diff --git a/wp-includes/random_compat/random_bytes_com_dotnet.php b/wp-includes/random_compat/random_bytes_com_dotnet.php index 0a781f4e..34228254 100644 --- a/wp-includes/random_compat/random_bytes_com_dotnet.php +++ b/wp-includes/random_compat/random_bytes_com_dotnet.php @@ -46,14 +46,17 @@ function random_bytes($bytes) 'random_bytes(): $bytes must be an integer' ); } + if ($bytes < 1) { throw new Error( 'Length must be greater than 0' ); } + $buf = ''; $util = new COM('CAPICOM.Utilities.1'); $execCount = 0; + /** * Let's not let it loop forever. If we run N times and fail to * get N bytes of random data, then CAPICOM has failed us. @@ -68,6 +71,7 @@ function random_bytes($bytes) } ++$execCount; } while ($execCount < $bytes); + /** * If we reach here, PHP has failed us. */