Fix logic error reading random bytes from /dev/urandom

Fixes a bug introduced in c2be7e648

Previously, this would return those bytes if the number of bytes read
was **less than** the number of bytes this was trying to read.

In practice, I believe this would mean bytes from /dev/urandom would never
get used.  (Noticed when upgrading phpseclib)
This commit is contained in:
Tyson Andre 2020-04-02 14:32:12 -04:00 committed by terrafrost
parent 5e2951f83a
commit 41eb0d8012

View File

@ -106,7 +106,7 @@ if (!function_exists('crypt_random_string')) {
}
if ($fp !== true && $fp !== false) { // surprisingly faster than !is_bool() or is_resource()
$temp = fread($fp, $length);
if (strlen($temp) != $length) {
if (strlen($temp) == $length) {
return $temp;
}
}