Update Random_Compat from 1.1.6 to 1.2.1.

Changes: https://github.com/paragonie/random_compat/compare/1.1.6...v1.2.1

See #35665.
Built from https://develop.svn.wordpress.org/trunk@36886


git-svn-id: http://core.svn.wordpress.org/trunk@36853 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling
2016-03-08 17:15:27 +00:00
parent 75c2005a49
commit 67475a943f
11 changed files with 135 additions and 48 deletions

View File

@@ -62,6 +62,7 @@ function random_bytes($bytes)
$fp = false;
}
}
if (!empty($fp)) {
/**
* stream_set_read_buffer() does not exist in HHVM
@@ -79,6 +80,7 @@ function random_bytes($bytes)
}
}
}
try {
$bytes = RandomCompat_intval($bytes);
} catch (TypeError $ex) {
@@ -86,11 +88,13 @@ function random_bytes($bytes)
'random_bytes(): $bytes must be an integer'
);
}
if ($bytes < 1) {
throw new Error(
'Length must be greater than 0'
);
}
/**
* This if() block only runs if we managed to open a file handle
*
@@ -101,6 +105,7 @@ function random_bytes($bytes)
if (!empty($fp)) {
$remaining = $bytes;
$buf = '';
/**
* We use fread() in a loop to protect against partial reads
*/
@@ -133,6 +138,7 @@ function random_bytes($bytes)
}
}
}
/**
* If we reach here, PHP has failed us.
*/