]> granicus.if.org Git - php/commitdiff
Don't return null from password_get_info()
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 11 Feb 2021 09:21:31 +0000 (10:21 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 11 Feb 2021 09:21:31 +0000 (10:21 +0100)
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.

ext/standard/basic_functions.stub.php
ext/standard/basic_functions_arginfo.h
ext/standard/password.c

index 7776e7765d8fef902bda393d1beb9625af6b2e6f..e83c89d4bfb3310af319870c51987f6a5977d0f9 100755 (executable)
@@ -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 {}
 
index d19184fbe65271fb5a95fccb80042624af6870b6..801fb2bcb170857726ba74434658382c7af7966b 100644 (file)
@@ -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()
 
index a19266d21475c6e30688532ba1e019a73a000b4f..c108f8d71a22bd0e7d93524bce13ede5c7c12658 100644 (file)
@@ -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);
 }