diff options
author | foobar <sniper@php.net> | 2001-05-06 16:54:27 +0000 |
---|---|---|
committer | foobar <sniper@php.net> | 2001-05-06 16:54:27 +0000 |
commit | 8e006f81afa692ebef76e10b75de2b9361a480d5 (patch) | |
tree | e6162da5ad27c7fece4b74a2ea03f24cd8c4a120 /ext/standard/crypt.c | |
parent | d2cbd019e38d3ff520541c0bef783028d321027a (diff) | |
download | php-git-8e006f81afa692ebef76e10b75de2b9361a480d5.tar.gz |
Fix bug: #8834. Now there should be more random salts..
Diffstat (limited to 'ext/standard/crypt.c')
-rw-r--r-- | ext/standard/crypt.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index 41f35cd31b..011242acc0 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -89,6 +89,7 @@ extern char *crypt(char *__key,char *__salt); #define PHP_CRYPT_RAND php_rand() +static int php_crypt_rand_seeded=0; PHP_MINIT_FUNCTION(crypt) { @@ -102,11 +103,20 @@ PHP_MINIT_FUNCTION(crypt) REGISTER_LONG_CONSTANT("CRYPT_MD5", PHP_MD5_CRYPT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP_BLOWFISH_CRYPT, CONST_CS | CONST_PERSISTENT); - php_srand(time(0) * getpid() * (php_combined_lcg() * 10000.0)); + return SUCCESS; +} + +PHP_RINIT_FUNCTION(crypt) +{ + if(!php_crypt_rand_seeded) { + php_srand(time(0) * getpid() * (php_combined_lcg() * 10000.0)); + php_crypt_rand_seeded=1; + } return SUCCESS; } + static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; static void php_to64(char *s, long v, int n) { |