cvs: php3 /functions crypt.c

From: Date: Fri, 03 Nov 2000 16:08:14 +0000
Subject: cvs: php3 /functions crypt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2461@lists.php.net to get a copy of this message
andi Fri Nov 3 08:08:14 2000 EDT Modified files: /php3/functions crypt.c Log: - Make crypt() correctly use a random seed each run. Index: php3/functions/crypt.c diff -u php3/functions/crypt.c:1.49 php3/functions/crypt.c:1.50 --- php3/functions/crypt.c:1.49 Fri Dec 31 20:31:14 1999 +++ php3/functions/crypt.c Fri Nov 3 08:08:14 2000 @@ -28,7 +28,7 @@ | Rasmus Lerdorf <rasmus@lerdorf.on.ca> | +----------------------------------------------------------------------+ */ -/* $Id: crypt.c,v 1.49 2000/01/01 04:31:14 sas Exp $ */ +/* $Id: crypt.c,v 1.50 2000/11/03 16:08:14 andi Exp $ */ #include <stdlib.h> #include "php.h" @@ -114,6 +114,17 @@ REGISTER_LONG_CONSTANT("CRYPT_EXT_DES", PHP3_EXT_DES_CRYPT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CRYPT_MD5", PHP3_MD5_CRYPT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP3_BLOWFISH_CRYPT, CONST_CS | CONST_PERSISTENT); + +#if HAVE_SRAND48 + srand48((unsigned int) time(0) * getpid()); +#else +#if HAVE_SRANDOM + srandom((unsigned int) time(0) * getpid()); +#else + srand((unsigned int) time(0) * getpid()); +#endif +#endif + return SUCCESS; } @@ -156,16 +167,6 @@ /* The automatic salt generation only covers standard DES and md5-crypt */ if(!*salt) { -#if HAVE_SRAND48 - srand48((unsigned int) time(0) * getpid()); -#else -#if HAVE_SRANDOM - srandom((unsigned int) time(0) * getpid()); -#else - srand((unsigned int) time(0) * getpid()); -#endif -#endif - #if PHP3_STD_DES_CRYPT php3i_to64(&salt[0], PHP3_CRYPT_RAND, 2); salt[2] = '\0';

« previous php.cvs (#2461) next »