X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2FCryptRand.php;h=859d58b5ddb151a1fd2f620206b52f525191d2c9;hb=e3af1c598b81cfb21de23b3da248f71109ebdd30;hp=0d3613ae230c4d493093bb2f929f2fcf2ff47e56;hpb=eb72adcb4e28eedc1806d845355856bd6f97dadb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/CryptRand.php b/includes/libs/CryptRand.php index 0d3613ae23..859d58b5dd 100644 --- a/includes/libs/CryptRand.php +++ b/includes/libs/CryptRand.php @@ -234,7 +234,6 @@ class CryptRand { * @return string Raw binary random data */ public function generate( $bytes, $forceStrong = false ) { - $bytes = floor( $bytes ); static $buffer = ''; if ( is_null( $this->strong ) ) { @@ -247,8 +246,11 @@ class CryptRand { // On Linux, getrandom syscall will be used if available. // On Windows CryptGenRandom will always be used // On other platforms, /dev/urandom will be used. + // Avoids polyfills from before php 7.0 // All error situations will throw Exceptions and or Errors - if ( function_exists( 'random_bytes' ) ) { + if ( PHP_VERSION_ID >= 70000 + || ( defined( 'HHVM_VERSION_ID' ) && HHVM_VERSION_ID >= 31101 ) + ) { $rem = $bytes - strlen( $buffer ); $buffer .= random_bytes( $rem ); }