summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2000-11-03 00:45:24 +0000
committerAndi Gutmans <andi@php.net>2000-11-03 00:45:24 +0000
commit139d5c102bdc9bdb75162ed40d0b18eaaf454818 (patch)
treed1340c9a2ca3dacc7f9c9b8aa672ee1328eb946b /ext
parent6451d5845526a632fd06737a3f74683b4f151258 (diff)
downloadphp-git-139d5c102bdc9bdb75162ed40d0b18eaaf454818.tar.gz
- Make the random generator work again. This patch seems to work.
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/crypt.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index 04facf4069..5ca0fa11f5 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -103,7 +103,16 @@ PHP_MINIT_FUNCTION(crypt)
REGISTER_LONG_CONSTANT("CRYPT_STD_DES", PHP_STD_DES_CRYPT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CRYPT_EXT_DES", PHP_EXT_DES_CRYPT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CRYPT_MD5", PHP_MD5_CRYPT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP_BLOWFISH_CRYPT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("CRYPT_BLOWFISH", PHP_BLOWFISH_CRYPT, CONST_CS | CONST_PERSISTENT);
+
+#if HAVE_SRAND48
+ srand48((unsigned int) time(0) * getpid() * (php_combined_lcg() * 10000.0));
+#elif HAVE_SRANDOM
+ srandom((unsigned int) time(0) * getpid() * (php_combined_lcg() * 10000.0));
+#else
+ srand((unsigned int) time(0) * getpid() * (php_combined_lcg() * 10000.0));
+#endif
+
return SUCCESS;
}
@@ -139,7 +148,7 @@ PHP_FUNCTION(crypt)
RETURN_FALSE;
}
convert_to_string_ex(arg2);
- memcpy(salt, (*arg2)->value.str.val, MIN(PHP_MAX_SALT_LEN,(*arg2)->value.str.len));
+ memcpy(salt, Z_STRVAL_PP(arg2), MIN(PHP_MAX_SALT_LEN, Z_STRLEN_PP(arg2)));
break;
default:
WRONG_PARAM_COUNT;
@@ -149,14 +158,6 @@ PHP_FUNCTION(crypt)
/* The automatic salt generation only covers standard DES and md5-crypt */
if(!*salt) {
-#if HAVE_SRAND48
- srand48((unsigned int) time(0) * getpid() * (php_combined_lcg() * 10000.0));
-#elif HAVE_SRANDOM
- srandom((unsigned int) time(0) * getpid() * (php_combined_lcg() * 10000.0));
-#else
- srand((unsigned int) time(0) * getpid() * (php_combined_lcg() * 10000.0));
-#endif
-
#if PHP_STD_DES_CRYPT
php_to64(&salt[0], PHP_CRYPT_RAND, 2);
salt[2] = '\0';
@@ -168,7 +169,7 @@ PHP_FUNCTION(crypt)
#endif
}
- return_value->value.str.val = (char *) crypt((*arg1)->value.str.val, salt);
+ return_value->value.str.val = (char *) crypt(Z_STRVAL_PP(arg1), salt);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
pval_copy_constructor(return_value);