[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_28]: CryptRand: only use random_bytes on php 7 and HHVM

2017-08-27 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/374109 )

Change subject: CryptRand: only use random_bytes on php 7 and HHVM
..


CryptRand: only use random_bytes on php 7 and HHVM

This avoids random_bytes polyfills used on older versions of PHP or
HHVM. HHVM has had random_bytes longer than PHP so treat it separately.

Bug: T143788
Change-Id: Ic9e511ccc043d50e0a9051cdfe069c27e4f4c339
(cherry picked from commit 9272d7717d8b526e966928e851451a257a26b0a5)
---
M includes/libs/CryptRand.php
1 file changed, 4 insertions(+), 1 deletion(-)

Approvals:
  Reedy: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/libs/CryptRand.php b/includes/libs/CryptRand.php
index 83948cf..73ce937 100644
--- a/includes/libs/CryptRand.php
+++ b/includes/libs/CryptRand.php
@@ -249,8 +249,11 @@
// 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 >= 7
+   || ( defined( 'HHVM_VERSION_ID' ) && 
HHVM_VERSION_ID >= 31101 )
+   ) {
$rem = $bytes - strlen( $buffer );
$buffer .= random_bytes( $rem );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/374109
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9e511ccc043d50e0a9051cdfe069c27e4f4c339
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_28
Gerrit-Owner: Reedy 
Gerrit-Reviewer: Reedy 
Gerrit-Reviewer: TheDJ 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[REL1_28]: CryptRand: only use random_bytes on php 7 and HHVM

2017-08-27 Thread Reedy (Code Review)
Reedy has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/374109 )

Change subject: CryptRand: only use random_bytes on php 7 and HHVM
..

CryptRand: only use random_bytes on php 7 and HHVM

This avoids random_bytes polyfills used on older versions of PHP or
HHVM. HHVM has had random_bytes longer than PHP so treat it separately.

Bug: T143788
Change-Id: Ic9e511ccc043d50e0a9051cdfe069c27e4f4c339
(cherry picked from commit 9272d7717d8b526e966928e851451a257a26b0a5)
---
M includes/libs/CryptRand.php
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/09/374109/1

diff --git a/includes/libs/CryptRand.php b/includes/libs/CryptRand.php
index 83948cf..73ce937 100644
--- a/includes/libs/CryptRand.php
+++ b/includes/libs/CryptRand.php
@@ -249,8 +249,11 @@
// 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 >= 7
+   || ( defined( 'HHVM_VERSION_ID' ) && 
HHVM_VERSION_ID >= 31101 )
+   ) {
$rem = $bytes - strlen( $buffer );
$buffer .= random_bytes( $rem );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/374109
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic9e511ccc043d50e0a9051cdfe069c27e4f4c339
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_28
Gerrit-Owner: Reedy 
Gerrit-Reviewer: TheDJ 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits