summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott <scott@paragonie.com>2016-03-09 08:04:17 -0500
committerScott <scott@paragonie.com>2016-03-09 08:04:17 -0500
commitcb4b63fff6313e928556a9865ddaaf8daf0da0ec (patch)
tree6648b8c2e49f67eff318461eff958e97819906d3
parentabe5c4aa4fac4362345224982ea672f033bb7d59 (diff)
downloadrandom_compat-cb4b63fff6313e928556a9865ddaaf8daf0da0ec.zip
random_compat-cb4b63fff6313e928556a9865ddaaf8daf0da0ec.tar.gz
random_compat-cb4b63fff6313e928556a9865ddaaf8daf0da0ec.tar.bz2
Unixy: Don't try mcrypt if urandom is unavailable
See #94
-rw-r--r--lib/random.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/random.php b/lib/random.php
index c77e0a0..c346dbe 100644
--- a/lib/random.php
+++ b/lib/random.php
@@ -117,7 +117,8 @@ if (PHP_VERSION_ID < 70000) {
}
// Unset variables after use
$RandomCompat_basedir = null;
- $RandomCompatUrandom = null;
+ } else {
+ $RandomCompatUrandom = false;
}
/**
@@ -129,6 +130,8 @@ if (PHP_VERSION_ID < 70000) {
PHP_VERSION_ID >= 50307
&&
extension_loaded('mcrypt')
+ &&
+ (DIRECTORY_SEPARATOR !== '/' || $RandomCompatUrandom)
) {
// Prevent this code from hanging indefinitely on non-Windows;
// see https://bugs.php.net/bug.php?id=69833
@@ -140,6 +143,7 @@ if (PHP_VERSION_ID < 70000) {
require_once $RandomCompatDIR.'/random_bytes_mcrypt.php';
}
}
+ $RandomCompatUrandom = null;
if (
!function_exists('random_bytes')