PHP_MINIT(file)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(pack)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(browscap)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(lcg)(INIT_FUNC_ARGS_PASSTHRU);
#if defined(HAVE_LOCALECONV) && defined(ZTS)
PHP_MINIT(localeconv)(INIT_FUNC_ARGS_PASSTHRU);
#endif
#endif
BG(user_shutdown_function_names)=NULL;
+#ifdef HAVE_CRYPT
+ PHP_RINIT(crypt)(INIT_FUNC_ARGS_PASSTHRU);
+#endif
+
+ PHP_RINIT(lcg)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(head)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
#define PHP_CRYPT_RAND php_rand()
+static int php_crypt_rand_seeded=0;
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) {
static php_lcg_globals lcg_globals;
#endif
+static int php_lcg_initialized = 0;
+
#ifdef PHP_WIN32
#include <process.h>
#endif
#endif
}
-PHP_MINIT_FUNCTION(lcg)
+PHP_RINIT_FUNCTION(lcg)
{
+ if (!php_lcg_initialized) {
#ifdef ZTS
- lcg_globals_id = ts_allocate_id(sizeof(php_lcg_globals), (ts_allocate_ctor) lcg_init_globals, NULL);
+ lcg_globals_id = ts_allocate_id(sizeof(php_lcg_globals), (ts_allocate_ctor) lcg_init_globals, NULL);
#else
- lcg_init_globals();
+ lcg_init_globals();
#endif
+ php_lcg_initialized = 1;
+ }
return SUCCESS;
}
PHP_FUNCTION(crypt);
#if HAVE_CRYPT
extern PHP_MINIT_FUNCTION(crypt);
+extern PHP_RINIT_FUNCTION(crypt);
#endif
#endif
double php_combined_lcg(void);
PHP_FUNCTION(lcg_value);
-PHP_MINIT_FUNCTION(lcg);
+PHP_RINIT_FUNCTION(lcg);
#ifdef ZTS
#define LCGLS_D php_lcg_globals *lcg_globals