Skip to content

Commit cec5e30

Browse files
committed
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.
1 parent d80d918 commit cec5e30

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ function unpack(string $format, string $string, int $offset = 0): array|false {}
11361136

11371137
/* password.c */
11381138

1139-
function password_get_info(string $hash): ?array {}
1139+
function password_get_info(string $hash): array {}
11401140

11411141
function password_hash(string $password, string|int|null $algo, array $options = []): string {}
11421142

ext/standard/basic_functions_arginfo.h

Lines changed: 2 additions & 2 deletions
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: 21e54280829776de72313b96e38ad2aee60bd0ee */
2+
* Stub hash: 39cd1ddd82efd6b62605218faff8b720d8b97170 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
55
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
17461746
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, offset, IS_LONG, 0, "0")
17471747
ZEND_END_ARG_INFO()
17481748

1749-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_password_get_info, 0, 1, IS_ARRAY, 1)
1749+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_password_get_info, 0, 1, IS_ARRAY, 0)
17501750
ZEND_ARG_TYPE_INFO(0, hash, IS_STRING, 0)
17511751
ZEND_END_ARG_INFO()
17521752

ext/standard/password.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,8 @@ PHP_FUNCTION(password_get_info)
584584
zend_string_release(ident);
585585

586586
add_assoc_string(return_value, "algoName", algo->name);
587-
if (algo->get_info &&
588-
(FAILURE == algo->get_info(&options, hash))) {
589-
zval_ptr_dtor_nogc(&options);
590-
zval_ptr_dtor_nogc(return_value);
591-
RETURN_NULL();
587+
if (algo->get_info) {
588+
algo->get_info(&options, hash);
592589
}
593590
add_assoc_zval(return_value, "options", &options);
594591
}

0 commit comments

Comments
 (0)