diff options
| author | Lucian Sirbu <lucian.sirbu@dcsplus.net> | 2019-04-09 15:50:00 +0300 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2019-04-11 17:20:49 +0200 |
| commit | 4bfc3b28eaa5aca9d00c03394442ac72d9ac4bb8 (patch) | |
| tree | 1330819243844857ced66812e5f756103046e973 /session | |
| parent | 93f13fd8e92ce7349ad84752c68235b252b88468 (diff) | |
| download | adodb-4bfc3b28eaa5aca9d00c03394442ac72d9ac4bb8.tar.gz adodb-4bfc3b28eaa5aca9d00c03394442ac72d9ac4bb8.tar.bz2 adodb-4bfc3b28eaa5aca9d00c03394442ac72d9ac4bb8.zip | |
Remove unnecessary srand() calls
srand() should not be called manually, unless one has a better way to
initialise the already-initialised random seed.
The way the current srand() call is made is buggy, and will lead to
duplicate random seeds if called often enough. Because the current call
will lose the timestamp part, and will only use the first 6 chars from
the current microsecond, but the system might not have a high-enough
timer resolution, so the actual pool of random seeds gets even smaller.
Fixes #532
Signed-off-by: Damien Regad <dregad@mantisbt.org>
Diffstat (limited to 'session')
| -rw-r--r-- | session/crypt.inc.php | 5 | ||||
| -rw-r--r-- | session/old/crypt.inc.php | 2 |
2 files changed, 0 insertions, 7 deletions
diff --git a/session/crypt.inc.php b/session/crypt.inc.php index 1468cb1a..94aa2831 100644 --- a/session/crypt.inc.php +++ b/session/crypt.inc.php @@ -16,7 +16,6 @@ class MD5Crypt{ function Encrypt($txt,$key) { - srand((double)microtime()*1000000); $encrypt_key = md5(rand(0,32000)); $ctr=0; $tmp = ""; @@ -45,7 +44,6 @@ class MD5Crypt{ function RandPass() { $randomPassword = ""; - srand((double)microtime()*1000000); for($i=0;$i<8;$i++) { $randnumber = rand(48,120); @@ -83,7 +81,6 @@ class SHA1Crypt{ function Encrypt($txt,$key) { - srand((double)microtime()*1000000); $encrypt_key = sha1(rand(0,32000)); $ctr=0; $tmp = ""; @@ -133,8 +130,6 @@ class SHA1Crypt{ function RandPass() { $randomPassword = ""; - srand((double)microtime()*1000000); - for($i=0;$i<8;$i++) { diff --git a/session/old/crypt.inc.php b/session/old/crypt.inc.php index 9c347db0..1ce75feb 100644 --- a/session/old/crypt.inc.php +++ b/session/old/crypt.inc.php @@ -16,7 +16,6 @@ class MD5Crypt{ function Encrypt($txt,$key) { - srand((double)microtime()*1000000); $encrypt_key = md5(rand(0,32000)); $ctr=0; $tmp = ""; @@ -45,7 +44,6 @@ class MD5Crypt{ function RandPass() { $randomPassword = ""; - srand((double)microtime()*1000000); for($i=0;$i<8;$i++) { $randnumber = rand(48,120); |
