From b981662855d06cce77e78d35ccbb6656b10bea22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Mon, 22 Jun 2020 22:38:01 +0200 Subject: [PATCH] Fix a couple of UNKNOWN default values in ext/session Closes GH-5752 --- ext/session/session.c | 15 +- ext/session/session.stub.php | 10 +- ext/session/session_arginfo.h | 10 +- .../tests/session_cache_limiter_error.phpt | 163 ------------------ 4 files changed, 15 insertions(+), 183 deletions(-) delete mode 100644 ext/session/tests/session_cache_limiter_error.phpt diff --git a/ext/session/session.c b/ext/session/session.c index 483bf4dd0f..0b190f0496 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1849,7 +1849,7 @@ PHP_FUNCTION(session_name) zend_string *name = NULL; zend_string *ini_name; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &name) == FAILURE) { RETURN_THROWS(); } @@ -1880,7 +1880,7 @@ PHP_FUNCTION(session_module_name) zend_string *name = NULL; zend_string *ini_name; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &name) == FAILURE) { RETURN_THROWS(); } @@ -2103,7 +2103,7 @@ PHP_FUNCTION(session_save_path) zend_string *name = NULL; zend_string *ini_name; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &name) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|P!", &name) == FAILURE) { RETURN_THROWS(); } @@ -2120,11 +2120,6 @@ PHP_FUNCTION(session_save_path) RETVAL_STRING(PS(save_path)); if (name) { - if (memchr(ZSTR_VAL(name), '\0', ZSTR_LEN(name)) != NULL) { - php_error_docref(NULL, E_WARNING, "The save_path cannot contain NULL characters"); - zval_ptr_dtor_str(return_value); - RETURN_FALSE; - } ini_name = zend_string_init("session.save_path", sizeof("session.save_path") - 1, 0); zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); @@ -2139,7 +2134,7 @@ PHP_FUNCTION(session_id) zend_string *name = NULL; int argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(argc, "|S", &name) == FAILURE) { + if (zend_parse_parameters(argc, "|S!", &name) == FAILURE) { RETURN_THROWS(); } @@ -2337,7 +2332,7 @@ PHP_FUNCTION(session_cache_limiter) zend_string *limiter = NULL; zend_string *ini_name; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S", &limiter) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &limiter) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/session/session.stub.php b/ext/session/session.stub.php index 24942aba9b..336a35b731 100644 --- a/ext/session/session.stub.php +++ b/ext/session/session.stub.php @@ -2,13 +2,13 @@ /** @generate-function-entries */ -function session_name(string $name = UNKNOWN): string|false {} +function session_name(?string $name = null): string|false {} -function session_module_name(string $module = UNKNOWN): string|false {} +function session_module_name(?string $module = null): string|false {} -function session_save_path(string $path = UNKNOWN): string|false {} +function session_save_path(?string $path = null): string|false {} -function session_id(string $id = UNKNOWN): string|false {} +function session_id(?string $id = null): string|false {} function session_create_id(string $prefix = ""): string|false {} @@ -41,7 +41,7 @@ function session_commit(): bool {} function session_set_save_handler($open, $close = UNKNOWN, $read = UNKNOWN, $write = UNKNOWN, $destroy = UNKNOWN, $gc = UNKNOWN, $create_sid = UNKNOWN, $validate_sid = UNKNOWN, $update_timestamp = UNKNOWN): bool {} -function session_cache_limiter(string $cache_limiter = UNKNOWN): string|false {} +function session_cache_limiter(?string $cache_limiter = null): string|false {} function session_cache_expire(?int $new_cache_expire = null): int|false {} diff --git a/ext/session/session_arginfo.h b/ext/session/session_arginfo.h index cae8d4fd25..69f54cf851 100644 --- a/ext/session/session_arginfo.h +++ b/ext/session/session_arginfo.h @@ -1,19 +1,19 @@ /* This is a generated file, edit the .stub.php file instead. */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_module_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, module, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, module, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_save_path, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, path, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_id, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, id, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_create_id, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) @@ -69,7 +69,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_set_save_handler, 0, 1, ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_cache_limiter, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, cache_limiter, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cache_limiter, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_cache_expire, 0, 0, MAY_BE_LONG|MAY_BE_FALSE) diff --git a/ext/session/tests/session_cache_limiter_error.phpt b/ext/session/tests/session_cache_limiter_error.phpt deleted file mode 100644 index d291d531c0..0000000000 --- a/ext/session/tests/session_cache_limiter_error.phpt +++ /dev/null @@ -1,163 +0,0 @@ ---TEST-- -Test session_cache_limiter() function : error functionality ---SKIPIF-- - ---FILE-- - ---EXPECT-- -*** Testing session_cache_limiter() : error functionality *** - --- Iteration 1 -- -string(7) "nocache" - --- Iteration 2 -- -string(1) "0" - --- Iteration 3 -- -string(1) "1" - --- Iteration 4 -- -string(5) "12345" - --- Iteration 5 -- -string(5) "-2345" - --- Iteration 6 -- -string(4) "10.5" - --- Iteration 7 -- -string(5) "-10.5" - --- Iteration 8 -- -string(12) "123456789000" - --- Iteration 9 -- -string(13) "1.23456789E-9" - --- Iteration 10 -- -string(3) "0.5" - --- Iteration 11 -- -string(0) "" - --- Iteration 12 -- -string(0) "" - --- Iteration 13 -- -string(1) "1" - --- Iteration 14 -- -string(0) "" - --- Iteration 15 -- -string(1) "1" - --- Iteration 16 -- -string(0) "" - --- Iteration 17 -- -string(0) "" - --- Iteration 18 -- -string(0) "" - --- Iteration 19 -- -string(7) "Nothing" - --- Iteration 20 -- -string(7) "Nothing" - --- Iteration 21 -- -string(12) "Hello World!" - --- Iteration 22 -- -string(12) "Hello World!" - --- Iteration 23 -- -string(0) "" -Done -- 2.40.0