]> granicus.if.org Git - php/commitdiff
Moved the RINIT(crypt) stuff into crypt() itself.
authorfoobar <sniper@php.net>
Mon, 11 Aug 2003 00:49:19 +0000 (00:49 +0000)
committerfoobar <sniper@php.net>
Mon, 11 Aug 2003 00:49:19 +0000 (00:49 +0000)
ext/standard/basic_functions.c
ext/standard/crypt.c

index 24c2fe5b895c3af9779bb2c40c4789e4ff166bde..b8c77bfc74da3bb18b7de72b8027f69edef56631 100644 (file)
@@ -1192,10 +1192,6 @@ PHP_RINIT_FUNCTION(basic)
 #endif
        BG(user_shutdown_function_names) = NULL;
 
-#if HAVE_CRYPT
-       PHP_RINIT(crypt)(INIT_FUNC_ARGS_PASSTHRU);
-#endif
-
        PHP_RINIT(lcg)(INIT_FUNC_ARGS_PASSTHRU);
 
        PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU);
index 45559e54848aa18d94b42f9015439dfe7d02a3b0..0844e34679f7b0f87f1067fa3bb6bd356bac1412 100644 (file)
@@ -89,8 +89,6 @@ extern char *crypt(char *__key, char *__salt);
 
 #define PHP_CRYPT_RAND php_rand(TSRMLS_C)
 
-static int php_crypt_rand_seeded=0;
-
 PHP_MINIT_FUNCTION(crypt)
 {
        REGISTER_LONG_CONSTANT("CRYPT_SALT_LENGTH", PHP_MAX_SALT_LEN, CONST_CS | CONST_PERSISTENT);
@@ -103,16 +101,6 @@ PHP_MINIT_FUNCTION(crypt)
 }
 
 
-PHP_RINIT_FUNCTION(crypt)
-{
-       if(!php_crypt_rand_seeded) {
-               php_srand(time(0) * getpid() * (unsigned long) (php_combined_lcg(TSRMLS_C) * 10000.0) TSRMLS_CC);
-               php_crypt_rand_seeded=1;
-       } 
-       return SUCCESS;
-}
-
-
 static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
 static void php_to64(char *s, long v, int n)
@@ -131,6 +119,10 @@ PHP_FUNCTION(crypt)
        char *str, *salt_in = NULL;
        int str_len, salt_in_len;
 
+       if (!BG(rand_is_seeded)) {
+               php_srand(GENERATE_SEED() TSRMLS_CC);
+       } 
+
        salt[0]=salt[PHP_MAX_SALT_LEN]='\0';
        /* This will produce suitable results if people depend on DES-encryption
           available (passing always 2-character salt). At least for glibc6.1 */