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.

git-svn-id: https://develop.svn.wordpress.org/trunk@36886 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90)
2016-03-08 17:14:52 +00:00
parent 5064747619
commit dfc6f47841
10 changed files with 134 additions and 47 deletions

View File

@@ -46,14 +46,17 @@ function random_bytes($bytes)
'random_bytes(): $bytes must be an integer'
);
}
if ($bytes < 1) {
throw new Error(
'Length must be greater than 0'
);
}
$buf = '';
$util = new COM('CAPICOM.Utilities.1');
$execCount = 0;
/**
* Let's not let it loop forever. If we run N times and fail to
* get N bytes of random data, then CAPICOM has failed us.
@@ -68,6 +71,7 @@ function random_bytes($bytes)
}
++$execCount;
} while ($execCount < $bytes);
/**
* If we reach here, PHP has failed us.
*/