Commit 6d0aba68 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5843-security-insecure-generation-of-random-tokens' into '1.3-dev'

Resolve "Security: Insecure Generation of Random Tokens"

See merge request fusiondirectory/fd!319
Showing with 2 additions and 2 deletions
+2 -2
......@@ -2468,7 +2468,7 @@ if (!function_exists('random_int')) {
{
$range = $max - $min;
if ($range <= 0) {
return $min;
throw new Exception('Invalid range passed to random_int');
}
$log = log($range, 2);
......@@ -2483,7 +2483,7 @@ if (!function_exists('random_int')) {
if (!$strong || ($randomBytes === FALSE)) {
throw new Exception('Failed to get random bytes');
}
$rnd = unpack('C', $randomBytes)[1];
$rnd = unpack('Q', $randomBytes)[1];
// discard irrelevant bits
$rnd = $rnd & $filter;
} while ($rnd >= $range);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment