Skip to content

Commit 7cae6eb

Browse files
committed
Fix hash_pbkdf2 options parameter
The value needs to be initialized to NULL as it is optional. Furthermore, the parameter was completely missing in the stub signature. Closes GH-11731
1 parent b0bc057 commit 7cae6eb

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ PHP NEWS
3838
- GD:
3939
. Fix most of the external libgd test failures. (Michael Orlitzky)
4040

41+
- Hash:
42+
. Fix use-of-uninitialized-value in hash_pbkdf2(), fix missing $options
43+
parameter in signature. (ilutov)
44+
4145
- Intl:
4246
. Fix memory leak in MessageFormatter::format() on failure. (Girgias)
4347

ext/hash/hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ PHP_FUNCTION(hash_pbkdf2)
992992
bool raw_output = 0;
993993
const php_hash_ops *ops;
994994
void *context;
995-
HashTable *args;
995+
HashTable *args = NULL;
996996

997997
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sssl|lbh", &algo, &pass, &pass_len, &salt, &salt_len, &iterations, &length, &raw_output, &args) == FAILURE) {
998998
RETURN_THROWS();

ext/hash/hash.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function hash_algos(): array {}
4444
function hash_hmac_algos(): array {}
4545

4646
/** @refcount 1 */
47-
function hash_pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0, bool $binary = false): string {}
47+
function hash_pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0, bool $binary = false, array $options = []): string {}
4848

4949
function hash_equals(string $known_string, string $user_string): bool {}
5050

ext/hash/hash_arginfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 8b5131fd7bd88d1ec0211bcfcb5a4854418aa3c8 */
2+
* Stub hash: 66d99527cf6d7b37ff652bb78fa57d5e3d5c78d9 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash, 0, 2, IS_STRING, 0)
55
ZEND_ARG_TYPE_INFO(0, algo, IS_STRING, 0)
@@ -74,6 +74,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_pbkdf2, 0, 4, IS_STRING, 0)
7474
ZEND_ARG_TYPE_INFO(0, iterations, IS_LONG, 0)
7575
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 0, "0")
7676
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, binary, _IS_BOOL, 0, "false")
77+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
7778
ZEND_END_ARG_INFO()
7879

7980
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_hash_equals, 0, 2, _IS_BOOL, 0)

0 commit comments

Comments
 (0)