diff options
author | Scott <scott@paragonie.com> | 2016-02-29 12:23:30 -0500 |
---|---|---|
committer | Scott <scott@paragonie.com> | 2016-02-29 12:23:30 -0500 |
commit | 0407f3b4885a714fee0fbce7b165cd9af9439132 (patch) | |
tree | a1cf439430fd384cc893a210cc13ddd47b42cd95 | |
parent | 8d7dd3479ffca1cce42d4d903f09ba9185edde19 (diff) | |
download | random_compat-0407f3b4885a714fee0fbce7b165cd9af9439132.zip random_compat-0407f3b4885a714fee0fbce7b165cd9af9439132.tar.gz random_compat-0407f3b4885a714fee0fbce7b165cd9af9439132.tar.bz2 |
Correct fix (open_basedir wasn't the culprit)
-rw-r--r-- | lib/random.php | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/lib/random.php b/lib/random.php index f639c7b..ff6c7c7 100644 --- a/lib/random.php +++ b/lib/random.php @@ -114,6 +114,7 @@ if (PHP_VERSION_ID < 70000) { } // Unset variables after use $RandomCompat_basedir = null; + $RandomCompatUrandom = null; } /** @@ -123,27 +124,18 @@ if (PHP_VERSION_ID < 70000) { !function_exists('random_bytes') && PHP_VERSION_ID >= 50307 - && - // Prevent this code from hanging indefinitely; - // see https://bugs.php.net/bug.php?id=69833 - ( - PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613 - ) && extension_loaded('mcrypt') - && - // Windows, or open_basedir allows us to read /dev/urandom: - ( - DIRECTORY_SEPARATOR !== '/' || $RandomCompatUrandom - ) ) { - // See random_bytes_mcrypt.php - require_once $RandomCompatDIR.'/random_bytes_mcrypt.php'; - } - - // Unset variables after use - if (DIRECTORY_SEPARATOR === '/') { - $RandomCompatUrandom = null; + // Prevent this code from hanging indefinitely on non-Windows; + // see https://bugs.php.net/bug.php?id=69833 + if ( + DIRECTORY_SEPARATOR !== '/' || + (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) + ) { + // See random_bytes_mcrypt.php + require_once $RandomCompatDIR.'/random_bytes_mcrypt.php'; + } } if ( |