summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Ferrara <me@ircmaxell.com>2013-02-13 04:55:43 -0800
committerAnthony Ferrara <me@ircmaxell.com>2013-02-13 04:55:43 -0800
commitada5fc650cdec893f265c6a207faa407746dc064 (patch)
tree578eb550684e7c1bef77102ea3b3473370afa1f4
parentfc4ad2d46794ace07cbf04fe654a8bf546fc6764 (diff)
parentd4dd6d0c04c266529d5a9af87a18494e0ce4e717 (diff)
downloadpassword_compat-ada5fc650cdec893f265c6a207faa407746dc064.zip
password_compat-ada5fc650cdec893f265c6a207faa407746dc064.tar.gz
password_compat-ada5fc650cdec893f265c6a207faa407746dc064.tar.bz2
Merge pull request #19 from multiwebinc/patch-1
Update lib/password.php
-rw-r--r--lib/password.php20
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/password.php b/lib/password.php
index d3e95cb..a583845 100644
--- a/lib/password.php
+++ b/lib/password.php
@@ -94,18 +94,16 @@ if (!defined('PASSWORD_BCRYPT')) {
$buffer_valid = true;
}
}
- if (!$buffer_valid && file_exists('/dev/urandom')) {
- $f = @fopen('/dev/urandom', 'r');
- if ($f) {
+ if (!$buffer_valid && is_readable('/dev/urandom')) {
+ $f = fopen('/dev/urandom', 'r');
+ $read = strlen($buffer);
+ while ($read < $raw_length) {
+ $buffer .= fread($f, $raw_length - $read);
$read = strlen($buffer);
- while ($read < $raw_length) {
- $buffer .= fread($f, $raw_length - $read);
- $read = strlen($buffer);
- }
- fclose($f);
- if ($read >= $raw_length) {
- $buffer_valid = true;
- }
+ }
+ fclose($f);
+ if ($read >= $raw_length) {
+ $buffer_valid = true;
}
}
if (!$buffer_valid || strlen($buffer) < $raw_length) {