summaryrefslogtreecommitdiff
path: root/ext/standard/crypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/crypt.c')
-rw-r--r--ext/standard/crypt.c12
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) {