CVS update: php3/functions

From: Date: Fri, 18 Sep 1998 17:04:16 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-1241@lists.php.net to get a copy of this message
Date: Friday September 18, 1998 @ 13:04 Author: zeev Update of /repository/php3/functions In directory asf:/u2/tmp/cvs-serv14455/functions Modified Files: crypt.c Log Message: Arrange the code for crypt() a bit, fixes some cases that weren't taken care of properly before Index: php3/functions/crypt.c diff -c php3/functions/crypt.c:1.35 php3/functions/crypt.c:1.36 *** php3/functions/crypt.c:1.35 Thu Sep 10 19:57:17 1998 --- php3/functions/crypt.c Fri Sep 18 13:04:15 1998 *************** *** 26,32 **** | Authors: Stig Bakken | +----------------------------------------------------------------------+ */ ! /* $Id: crypt.c,v 1.35 1998/09/10 23:57:17 zeev Exp $ */ #include "php.h" #include "internal_functions.h" --- 26,32 ---- | Authors: Stig Bakken | +----------------------------------------------------------------------+ */ ! /* $Id: crypt.c,v 1.36 1998/09/18 17:04:15 zeev Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 68,93 **** void php3_crypt(INTERNAL_FUNCTION_PARAMETERS) { ! char salt[4]; ! int arg_count = ARG_COUNT(ht); pval *arg1, *arg2; static char seedchars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; ! if (arg_count < 1 || arg_count > 2 || ! getParameters(ht, arg_count, &arg1, &arg2) == FAILURE) { ! WRONG_PARAM_COUNT; } convert_to_string(arg1); ! salt[0] = '\0'; ! if (arg_count == 2) { ! convert_to_string(arg2); ! strncpy(salt, arg2->value.str.val, 2); ! } if (!salt[0]) { - srand(time(0) * getpid()); salt[0] = seedchars[rand() % 64]; salt[1] = seedchars[rand() % 64]; } salt[2] = '\0'; --- 68,104 ---- void php3_crypt(INTERNAL_FUNCTION_PARAMETERS) { ! char salt[3] = { '\0', '\0', '\0' }; pval *arg1, *arg2; static char seedchars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"; ! switch (ARG_COUNT(ht)) { ! case 1: ! if (getParameters(ht, 1, &arg1)==FAILURE) { ! RETURN_FALSE; ! } ! break; ! case 2: ! if (getParameters(ht, 2, &arg1, &arg2)==FAILURE) { ! RETURN_FALSE; ! } ! convert_to_string(arg2); ! memcpy(salt, arg2->value.str.val, MIN(2,arg2->value.str.len)); ! break; ! default: ! WRONG_PARAM_COUNT; ! break; } convert_to_string(arg1); ! srand(time(0) * getpid()); ! if (!salt[0]) { salt[0] = seedchars[rand() % 64]; + } + + if (!salt[1]) { salt[1] = seedchars[rand() % 64]; } salt[2] = '\0'; -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#1241) next »