From: Nikita Popov Date: Wed, 12 Mar 2014 13:09:34 +0000 (+0100) Subject: Fix hash_pbkdf2() with missing $length argument X-Git-Tag: php-5.5.11RC1~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06bbb657ad8ae4660051da1ad698370f0c06bdc4;p=php Fix hash_pbkdf2() with missing $length argument Also change the type of some string length variables to ensure that the zpp call works correctly on platforms where sizeof(int) != sizeof(long). --- diff --git a/NEWS b/NEWS index d1b2e5f5ea..a84d4193df 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,10 @@ PHP NEWS . Fixed bug #66869 (Invalid 2nd argument crashes imageaffinematrixget) (Pierre) . Fixed bug #66890 (imagescale segfault). (Remi) +- Hash: + . hash_pbkdf2() now works correctly if the $length argument is not specified. + (Nikita) + - Mail: . Fixed bug #66535 (Don't add newline after X-PHP-Originating-Script) (Tjerk) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 5222a395e6..28e70dcd2d 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -609,16 +609,15 @@ Generate a PBKDF2 hash of the given password and salt Returns lowercase hexits by default */ PHP_FUNCTION(hash_pbkdf2) { - char *returnval, *algo, *salt, *pass = NULL; - unsigned char *computed_salt, *digest, *temp, *result, *K1, *K2 = NULL; - long loops, i, j, algo_len, pass_len, iterations, length, digest_length = 0; - int argc, salt_len = 0; + char *returnval, *algo, *salt, *pass; + unsigned char *computed_salt, *digest, *temp, *result, *K1, *K2; + long loops, i, j, iterations, length = 0, digest_length; + int algo_len, pass_len, salt_len; zend_bool raw_output = 0; const php_hash_ops *ops; void *context; - argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argc TSRMLS_CC, "sssl|lb", &algo, &algo_len, &pass, &pass_len, &salt, &salt_len, &iterations, &length, &raw_output) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssl|lb", &algo, &algo_len, &pass, &pass_len, &salt, &salt_len, &iterations, &length, &raw_output) == FAILURE) { return; } diff --git a/ext/hash/tests/hash_pbkdf2_basic.phpt b/ext/hash/tests/hash_pbkdf2_basic.phpt index fdccc4b6ea..17610dfedc 100644 --- a/ext/hash/tests/hash_pbkdf2_basic.phpt +++ b/ext/hash/tests/hash_pbkdf2_basic.phpt @@ -5,7 +5,7 @@ Test hash_pbkdf2() function : basic functionality --FILE--