diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-02-11 10:21:31 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-02-11 10:21:31 +0100 |
commit | cec5e308899febe5692d34c8c5b78e6773284e45 (patch) | |
tree | e7ae0662a1b21d360899607659683c1c320085c2 | |
parent | d80d918547b676e78ccf096a24069a8b2e5dd96b (diff) | |
download | php-git-cec5e308899febe5692d34c8c5b78e6773284e45.tar.gz |
Don't return null from password_get_info()
The get_info() handler should never fail, but even if it does,
we should still return a proper info array -- it doesn't make
sense that a completely incorrect hash returns an info array,
but a hash that is recognized but for which the options can't
be extracted would return null.
-rwxr-xr-x | ext/standard/basic_functions.stub.php | 2 | ||||
-rw-r--r-- | ext/standard/basic_functions_arginfo.h | 4 | ||||
-rw-r--r-- | ext/standard/password.c | 7 |
3 files changed, 5 insertions, 8 deletions
diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 7776e7765d..e83c89d4bf 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1136,7 +1136,7 @@ function unpack(string $format, string $string, int $offset = 0): array|false {} /* password.c */ -function password_get_info(string $hash): ?array {} +function password_get_info(string $hash): array {} function password_hash(string $password, string|int|null $algo, array $options = []): string {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index d19184fbe6..801fb2bcb1 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 21e54280829776de72313b96e38ad2aee60bd0ee */ + * Stub hash: 39cd1ddd82efd6b62605218faff8b720d8b97170 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -1746,7 +1746,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_unpack, 0, 2, MAY_BE_ARRAY|MAY_B ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_password_get_info, 0, 1, IS_ARRAY, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_password_get_info, 0, 1, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, hash, IS_STRING, 0) ZEND_END_ARG_INFO() diff --git a/ext/standard/password.c b/ext/standard/password.c index a19266d214..c108f8d71a 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -584,11 +584,8 @@ PHP_FUNCTION(password_get_info) zend_string_release(ident); add_assoc_string(return_value, "algoName", algo->name); - if (algo->get_info && - (FAILURE == algo->get_info(&options, hash))) { - zval_ptr_dtor_nogc(&options); - zval_ptr_dtor_nogc(return_value); - RETURN_NULL(); + if (algo->get_info) { + algo->get_info(&options, hash); } add_assoc_zval(return_value, "options", &options); } |