cvs: php4 /ext/standard basic_functions.c crypt.c lcg.c php_crypt.h php_lcg.h
| From: | Jani Taskinen | Date: | Sun, 06 May 2001 16:54:28 +0000 |
| Subject: | cvs: php4 /ext/standard basic_functions.c crypt.c lcg.c php_crypt.h php_lcg.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-5564@lists.php.net to get a copy of this message | ||
sniper Sun May 6 09:54:28 2001 EDT
Modified files:
/php4/ext/standard basic_functions.c crypt.c lcg.c php_crypt.h
php_lcg.h
Log:
Fix bug: #8834. Now there should be more random salts..
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.327 php4/ext/standard/basic_functions.c:1.328
--- php4/ext/standard/basic_functions.c:1.327 Mon Apr 30 05:43:39 2001
+++ php4/ext/standard/basic_functions.c Sun May 6 09:54:27 2001
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.327 2001/04/30 12:43:39 andi Exp $ */
+/* $Id: basic_functions.c,v 1.328 2001/05/06 16:54:27 sniper Exp $ */
#include "php.h"
#include "php_main.h"
@@ -747,7 +747,6 @@
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
@@ -834,6 +833,11 @@
#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);
Index: php4/ext/standard/crypt.c
diff -u php4/ext/standard/crypt.c:1.39 php4/ext/standard/crypt.c:1.40
--- php4/ext/standard/crypt.c:1.39 Thu Apr 5 11:48:03 2001
+++ php4/ext/standard/crypt.c Sun May 6 09:54:27 2001
@@ -17,7 +17,7 @@
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: crypt.c,v 1.39 2001/04/05 18:48:03 sniper Exp $ */
+/* $Id: crypt.c,v 1.40 2001/05/06 16:54:27 sniper Exp $ */
#include <stdlib.h>
#include "php.h"
@@ -89,6 +89,7 @@
#define PHP_CRYPT_RAND php_rand()
+static int php_crypt_rand_seeded=0;
PHP_MINIT_FUNCTION(crypt)
{
@@ -102,10 +103,19 @@
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";
Index: php4/ext/standard/lcg.c
diff -u php4/ext/standard/lcg.c:1.15 php4/ext/standard/lcg.c:1.16
--- php4/ext/standard/lcg.c:1.15 Sun Feb 25 22:07:23 2001
+++ php4/ext/standard/lcg.c Sun May 6 09:54:27 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: lcg.c,v 1.15 2001/02/26 06:07:23 andi Exp $ */
+/* $Id: lcg.c,v 1.16 2001/05/06 16:54:27 sniper Exp $ */
#include "php.h"
#include "php_lcg.h"
@@ -31,6 +31,8 @@
static php_lcg_globals lcg_globals;
#endif
+static int php_lcg_initialized = 0;
+
#ifdef PHP_WIN32
#include <process.h>
#endif
@@ -71,13 +73,16 @@
#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;
}
Index: php4/ext/standard/php_crypt.h
diff -u php4/ext/standard/php_crypt.h:1.7 php4/ext/standard/php_crypt.h:1.8
--- php4/ext/standard/php_crypt.h:1.7 Sun Feb 25 22:07:23 2001
+++ php4/ext/standard/php_crypt.h Sun May 6 09:54:27 2001
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_crypt.h,v 1.7 2001/02/26 06:07:23 andi Exp $ */
+/* $Id: php_crypt.h,v 1.8 2001/05/06 16:54:27 sniper Exp $ */
#ifndef PHP_CRYPT_H
#define PHP_CRYPT_H
@@ -26,6 +26,7 @@
PHP_FUNCTION(crypt);
#if HAVE_CRYPT
extern PHP_MINIT_FUNCTION(crypt);
+extern PHP_RINIT_FUNCTION(crypt);
#endif
#endif
Index: php4/ext/standard/php_lcg.h
diff -u php4/ext/standard/php_lcg.h:1.9 php4/ext/standard/php_lcg.h:1.10
--- php4/ext/standard/php_lcg.h:1.9 Sun Feb 25 22:07:23 2001
+++ php4/ext/standard/php_lcg.h Sun May 6 09:54:27 2001
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_lcg.h,v 1.9 2001/02/26 06:07:23 andi Exp $ */
+/* $Id: php_lcg.h,v 1.10 2001/05/06 16:54:27 sniper Exp $ */
#ifndef PHP_LCG_H
#define PHP_LCG_H
@@ -28,7 +28,7 @@
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