From 9d5f2f1343a891eba122bdd0bd7fa8758fd4c493 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Mon, 20 Mar 2023 16:19:05 +0100 Subject: [PATCH] Use new ZSTR_INIT_LITERAL macro (#10879) --- Zend/zend_builtin_functions.c | 4 ++-- Zend/zend_compile.c | 8 +++---- Zend/zend_enum.c | 4 ++-- Zend/zend_exceptions.c | 2 +- Zend/zend_execute_API.c | 2 +- Zend/zend_language_parser.y | 4 ++-- ext/bcmath/bcmath.c | 2 +- ext/date/php_date.c | 2 +- ext/dom/php_dom.c | 2 +- ext/fileinfo/libmagic.patch | 2 +- ext/fileinfo/libmagic/softmagic.c | 2 +- ext/iconv/iconv.c | 6 ++--- ext/imap/php_imap.c | 2 +- ext/mbstring/mbstring.c | 2 +- ext/opcache/ZendAccelerator.c | 4 ++-- ext/pdo/pdo_dbh.c | 2 +- ext/pdo_dblib/dblib_stmt.c | 2 +- ext/pdo_firebird/firebird_driver.c | 2 +- ext/pdo_mysql/mysql_driver.c | 2 +- ext/pdo_oci/oci_driver.c | 2 +- ext/phar/phar_object.c | 2 +- ext/phar/stream.c | 2 +- ext/random/randomizer.c | 2 +- ext/session/session.c | 36 +++++++++++++++--------------- ext/soap/soap.c | 2 +- ext/sodium/sodium_pwhash.c | 2 +- ext/spl/spl_directory.c | 6 ++--- ext/spl/spl_iterators.c | 8 +++---- ext/standard/assert.c | 8 +++---- ext/standard/basic_functions.c | 4 ++-- ext/standard/http_fopen_wrapper.c | 2 +- ext/standard/password.c | 4 ++-- ext/standard/user_filters.c | 4 ++-- ext/xsl/xsltprocessor.c | 4 ++-- main/SAPI.c | 2 +- main/main.c | 2 +- sapi/fpm/fpm/fpm_status.c | 2 +- sapi/fuzzer/fuzzer-function-jit.c | 2 +- sapi/fuzzer/fuzzer-tracing-jit.c | 2 +- sapi/litespeed/lsapi_main.c | 2 +- 40 files changed, 78 insertions(+), 78 deletions(-) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 93cd9040dd3..c332f5a3220 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -110,7 +110,7 @@ ZEND_FUNCTION(gc_enable) ZEND_PARSE_PARAMETERS_NONE(); - key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0); + key = ZSTR_INIT_LITERAL("zend.enable_gc", 0); zend_alter_ini_entry_chars(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zend_string_release_ex(key, 0); } @@ -123,7 +123,7 @@ ZEND_FUNCTION(gc_disable) ZEND_PARSE_PARAMETERS_NONE(); - key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0); + key = ZSTR_INIT_LITERAL("zend.enable_gc", 0); zend_alter_ini_entry_chars(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zend_string_release_ex(key, 0); } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 711f33b568b..a082a71c481 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2016,7 +2016,7 @@ zend_ast *zend_negate_num_string(zend_ast *ast) /* {{{ */ zval *zv = zend_ast_get_zval(ast); if (Z_TYPE_P(zv) == IS_LONG) { if (Z_LVAL_P(zv) == 0) { - ZVAL_NEW_STR(zv, zend_string_init("-0", sizeof("-0")-1, 0)); + ZVAL_NEW_STR(zv, ZSTR_INIT_LITERAL("-0", 0)); } else { ZEND_ASSERT(Z_LVAL_P(zv) > 0); Z_LVAL_P(zv) *= -1; @@ -4221,7 +4221,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string /* If the original argument was named, add the new argument as named as well, * as mixing named and positional is not allowed. */ zend_ast *name = zend_ast_create_zval_from_str( - zend_string_init("description", sizeof("description") - 1, 0)); + ZSTR_INIT_LITERAL("description", 0)); arg = zend_ast_create(ZEND_AST_NAMED_ARG, name, arg); } zend_ast_list_add((zend_ast *) args, arg); @@ -7295,9 +7295,9 @@ static void add_stringable_interface(zend_class_entry *ce) { erealloc(ce->interface_names, sizeof(zend_class_name) * ce->num_interfaces); // TODO: Add known interned strings instead? ce->interface_names[ce->num_interfaces - 1].name = - zend_string_init("Stringable", sizeof("Stringable") - 1, 0); + ZSTR_INIT_LITERAL("Stringable", 0); ce->interface_names[ce->num_interfaces - 1].lc_name = - zend_string_init("stringable", sizeof("stringable") - 1, 0); + ZSTR_INIT_LITERAL("stringable", 0); } static zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string *name, bool has_body) /* {{{ */ diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index 4abca60fa85..21628f74956 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -183,11 +183,11 @@ void zend_enum_add_interfaces(zend_class_entry *ce) ce->interface_names = erealloc(ce->interface_names, sizeof(zend_class_name) * ce->num_interfaces); ce->interface_names[num_interfaces_before].name = zend_string_copy(zend_ce_unit_enum->name); - ce->interface_names[num_interfaces_before].lc_name = zend_string_init("unitenum", sizeof("unitenum") - 1, 0); + ce->interface_names[num_interfaces_before].lc_name = ZSTR_INIT_LITERAL("unitenum", 0); if (ce->enum_backing_type != IS_UNDEF) { ce->interface_names[num_interfaces_before + 1].name = zend_string_copy(zend_ce_backed_enum->name); - ce->interface_names[num_interfaces_before + 1].lc_name = zend_string_init("backedenum", sizeof("backedenum") - 1, 0); + ce->interface_names[num_interfaces_before + 1].lc_name = ZSTR_INIT_LITERAL("backedenum", 0); } ce->default_object_handlers = &zend_enum_object_handlers; diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 5846b51c662..8dea4804233 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -647,7 +647,7 @@ ZEND_METHOD(Exception, __toString) str = ZSTR_EMPTY_ALLOC(); exception = ZEND_THIS; - fname = zend_string_init("gettraceasstring", sizeof("gettraceasstring")-1, 0); + fname = ZSTR_INIT_LITERAL("gettraceasstring", 0); while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), zend_ce_throwable)) { zend_string *prev_str = str; diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 9b10db265da..9efe205abe0 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -572,7 +572,7 @@ ZEND_API zend_string *get_function_or_method_name(const zend_function *func) /* return zend_create_member_string(func->common.scope->name, func->common.function_name); } - return func->common.function_name ? zend_string_copy(func->common.function_name) : zend_string_init("main", sizeof("main") - 1, 0); + return func->common.function_name ? zend_string_copy(func->common.function_name) : ZSTR_INIT_LITERAL("main", 0); } /* }}} */ diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 1f9cdfb3c38..d1d54ade4df 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -1256,12 +1256,12 @@ inline_function: function returns_ref backup_doc_comment '(' parameter_list ')' lexical_vars return_type backup_fn_flags '{' inner_statement_list '}' backup_fn_flags { $$ = zend_ast_create_decl(ZEND_AST_CLOSURE, $2 | $13, $1, $3, - zend_string_init("{closure}", sizeof("{closure}") - 1, 0), + ZSTR_INIT_LITERAL("{closure}", 0), $5, $7, $11, $8, NULL); CG(extra_fn_flags) = $9; } | fn returns_ref backup_doc_comment '(' parameter_list ')' return_type T_DOUBLE_ARROW backup_fn_flags backup_lex_pos expr backup_fn_flags { $$ = zend_ast_create_decl(ZEND_AST_ARROW_FUNC, $2 | $12, $1, $3, - zend_string_init("{closure}", sizeof("{closure}") - 1, 0), $5, NULL, $11, $7, NULL); + ZSTR_INIT_LITERAL("{closure}", 0), $5, NULL, $11, $7, NULL); CG(extra_fn_flags) = $9; } ; diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index d6147269b0e..af36e399b01 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -633,7 +633,7 @@ PHP_FUNCTION(bcscale) RETURN_THROWS(); } - zend_string *ini_name = zend_string_init("bcmath.scale", sizeof("bcmath.scale") - 1, 0); + zend_string *ini_name = ZSTR_INIT_LITERAL("bcmath.scale", 0); zend_string *new_scale_str = zend_long_to_str(new_scale); zend_alter_ini_entry(ini_name, new_scale_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release(new_scale_str); diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 4219b6977f6..6b2e94c7185 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1650,7 +1650,7 @@ static void date_period_it_move_forward(zend_object_iterator *iter) } create_date_period_datetime(object->current, object->start_ce, ¤t_zv); - zend_string *property_name = zend_string_init("current", sizeof("current") - 1, 0); + zend_string *property_name = ZSTR_INIT_LITERAL("current", 0); zend_std_write_property(&object->std, property_name, ¤t_zv, NULL); zval_ptr_dtor(¤t_zv); zend_string_release(property_name); diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index d9463012f14..662c6e9ef7c 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -403,7 +403,7 @@ static HashTable* dom_get_debug_info_helper(zend_object *object, int *is_temp) / return debug_info; } - object_str = zend_string_init("(object value omitted)", sizeof("(object value omitted)")-1, 0); + object_str = ZSTR_INIT_LITERAL("(object value omitted)", 0); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(prop_handlers, string_key, entry) { zval value; diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index 908cc060804..a0c62be524f 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -2949,7 +2949,7 @@ diff -u libmagic.orig/softmagic.c libmagic/softmagic.c - if (rc == 0) { - rc = file_regexec(ms, &rx, fmt, 0, 0, 0); - rv = !rc; -+ pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0); ++ pattern = ZSTR_INIT_LITERAL("~%[-0-9\\.]*s~", 0); + if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) { + rv = -1; + } else { diff --git a/ext/fileinfo/libmagic/softmagic.c b/ext/fileinfo/libmagic/softmagic.c index afb77ba256e..32d24a37d3d 100644 --- a/ext/fileinfo/libmagic/softmagic.c +++ b/ext/fileinfo/libmagic/softmagic.c @@ -493,7 +493,7 @@ check_fmt(struct magic_set *ms, const char *fmt) if (strchr(fmt, '%') == NULL) return 0; - pattern = zend_string_init("~%[-0-9\\.]*s~", sizeof("~%[-0-9\\.]*s~") - 1, 0); + pattern = ZSTR_INIT_LITERAL("~%[-0-9\\.]*s~", 0); if ((pce = pcre_get_compiled_regex_cache_ex(pattern, 0)) == NULL) { rv = -1; } else { diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index e61c448c305..c2ed3f258bc 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -2236,11 +2236,11 @@ PHP_FUNCTION(iconv_set_encoding) } if(zend_string_equals_literal_ci(type, "input_encoding")) { - name = zend_string_init("iconv.input_encoding", sizeof("iconv.input_encoding") - 1, 0); + name = ZSTR_INIT_LITERAL("iconv.input_encoding", 0); } else if(zend_string_equals_literal_ci(type, "output_encoding")) { - name = zend_string_init("iconv.output_encoding", sizeof("iconv.output_encoding") - 1, 0); + name = ZSTR_INIT_LITERAL("iconv.output_encoding", 0); } else if(zend_string_equals_literal_ci(type, "internal_encoding")) { - name = zend_string_init("iconv.internal_encoding", sizeof("iconv.internal_encoding") - 1, 0); + name = ZSTR_INIT_LITERAL("iconv.internal_encoding", 0); } else { RETURN_FALSE; } diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c index 96d91a11f65..7723669417a 100644 --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@ -822,7 +822,7 @@ PHP_FUNCTION(imap_append) } if (internal_date) { - zend_string *regex = zend_string_init("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/", sizeof("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/") - 1, 0); + zend_string *regex = ZSTR_INIT_LITERAL("/[0-3][0-9]-((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec))-[0-9]{4} [0-2][0-9]:[0-5][0-9]:[0-5][0-9] [+-][0-9]{4}/", 0); pcre_cache_entry *pce; /* Compiled regex */ zval *subpats = NULL; /* Parts (not used) */ int global = 0; diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 3277284be51..d12d160153c 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -1203,7 +1203,7 @@ PHP_FUNCTION(mb_language) if (name == NULL) { RETVAL_STRING((char *)mbfl_no_language2name(MBSTRG(language))); } else { - zend_string *ini_name = zend_string_init("mbstring.language", sizeof("mbstring.language") - 1, 0); + zend_string *ini_name = ZSTR_INIT_LITERAL("mbstring.language", 0); if (FAILURE == zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)) { zend_argument_value_error(1, "must be a valid language, \"%s\" given", ZSTR_VAL(name)); zend_string_release_ex(ini_name, 0); diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 3d0254e8307..9f5992831d1 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2656,7 +2656,7 @@ zend_result accel_activate(INIT_FUNC_ARGS) ZCG(root_hash) = buf.st_ino; if (sizeof(buf.st_ino) > sizeof(ZCG(root_hash))) { if (ZCG(root_hash) != buf.st_ino) { - zend_string *key = zend_string_init("opcache.enable", sizeof("opcache.enable")-1, 0); + zend_string *key = ZSTR_INIT_LITERAL("opcache.enable", 0); zend_alter_ini_entry_chars(key, "0", 1, ZEND_INI_SYSTEM, ZEND_INI_STAGE_RUNTIME); zend_string_release_ex(key, 0); zend_accel_error(ACCEL_LOG_WARNING, "Can't cache files in chroot() directory with too big inode"); @@ -4479,7 +4479,7 @@ static zend_result accel_preload(const char *config, bool in_child) script->ping_auto_globals_mask = ping_auto_globals_mask; /* Store all functions and classes in a single pseudo-file */ - CG(compiled_filename) = zend_string_init("$PRELOAD$", sizeof("$PRELOAD$") - 1, 0); + CG(compiled_filename) = ZSTR_INIT_LITERAL("$PRELOAD$", 0); #if ZEND_USE_ABS_CONST_ADDR init_op_array(&script->script.main_op_array, ZEND_USER_FUNCTION, 1); #else diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 290587b5db1..b4664e60fb7 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -461,7 +461,7 @@ static void pdo_stmt_construct(zend_execute_data *execute_data, pdo_stmt_t *stmt zend_string *key; ZVAL_STR(&query_string, stmt->query_string); - key = zend_string_init("queryString", sizeof("queryString") - 1, 0); + key = ZSTR_INIT_LITERAL("queryString", 0); zend_std_write_property(Z_OBJ_P(object), key, &query_string, NULL); zend_string_release_ex(key, 0); diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c index 2a946c81dc2..acdbf7306d4 100644 --- a/ext/pdo_dblib/dblib_stmt.c +++ b/ext/pdo_dblib/dblib_stmt.c @@ -243,7 +243,7 @@ static int pdo_dblib_stmt_describe(pdo_stmt_t *stmt, int colno) len = snprintf(buf, sizeof(buf), "computed%d", S->computed_column_name_count); col->name = zend_string_init(buf, len, 0); } else { - col->name = zend_string_init("computed", strlen("computed"), 0); + col->name = ZSTR_INIT_LITERAL("computed", 0); } S->computed_column_name_count++; diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index 7dc40f510d4..cbd7ee7cfd3 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -671,7 +671,7 @@ static zend_string* firebird_handle_quoter(pdo_dbh_t *dbh, const zend_string *un zend_string *quoted_str; if (ZSTR_LEN(unquoted) == 0) { - return zend_string_init("''", 2, 0); + return ZSTR_INIT_LITERAL("''", 0); } /* Firebird only requires single quotes to be doubled if string lengths are used */ diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 698b4e2d28c..2907c6c0c87 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -356,7 +356,7 @@ static bool mysql_handle_begin(pdo_dbh_t *dbh) PDO_DBG_ENTER("mysql_handle_begin"); PDO_DBG_INF_FMT("dbh=%p", dbh); - command = zend_string_init("START TRANSACTION", strlen("START TRANSACTION"), 0); + command = ZSTR_INIT_LITERAL("START TRANSACTION", 0); return_value = mysql_handle_doer(dbh, command); zend_string_release_ex(command, 0); PDO_DBG_RETURN(0 <= return_value); diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c index f74c67ff4ed..6a16420b957 100644 --- a/ext/pdo_oci/oci_driver.c +++ b/ext/pdo_oci/oci_driver.c @@ -363,7 +363,7 @@ static zend_string* oci_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquote zend_string *quoted_str; if (ZSTR_LEN(unquoted) == 0) { - return zend_string_init("''", 2, 0); + return ZSTR_INIT_LITERAL("''", 0); } /* count single quotes */ diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 6a593b981a1..7791ddb10a0 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1435,7 +1435,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ } close_fp = 0; - opened = zend_string_init("[stream]", sizeof("[stream]") - 1, 0); + opened = ZSTR_INIT_LITERAL("[stream]", 0); goto after_open_fp; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo)) { diff --git a/ext/phar/stream.c b/ext/phar/stream.c index b45b662398c..e400699780e 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -84,7 +84,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const return NULL; } resource = ecalloc(1, sizeof(php_url)); - resource->scheme = zend_string_init("phar", 4, 0); + resource->scheme = ZSTR_INIT_LITERAL("phar", 0); resource->host = zend_string_init(arch, arch_len, 0); efree(arch); resource->path = zend_string_init(entry, entry_len, 0); diff --git a/ext/random/randomizer.c b/ext/random/randomizer.c index 6248d97f5b1..fe9ad5fc35a 100644 --- a/ext/random/randomizer.c +++ b/ext/random/randomizer.c @@ -42,7 +42,7 @@ static inline void randomizer_common_init(php_random_randomizer *randomizer, zen zend_string *mname; zend_function *generate_method; - mname = zend_string_init("generate", strlen("generate"), 0); + mname = ZSTR_INIT_LITERAL("generate", 0); generate_method = zend_hash_find_ptr(&engine_object->ce->function_table, mname); zend_string_release(mname); diff --git a/ext/session/session.c b/ext/session/session.c index 5c8cf470b33..66fbe7adaa3 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -215,7 +215,7 @@ PHPAPI zval* php_get_session_var(zend_string *name) /* {{{ */ static void php_session_track_init(void) /* {{{ */ { zval session_vars; - zend_string *var_name = zend_string_init("_SESSION", sizeof("_SESSION") - 1, 0); + zend_string *var_name = ZSTR_INIT_LITERAL("_SESSION", 0); /* Unconditionally destroy existing array -- possible dirty data */ zend_delete_global_variable(var_name); @@ -841,7 +841,7 @@ PS_SERIALIZER_DECODE_FUNC(php_serialize) /* {{{ */ zval session_vars; php_unserialize_data_t var_hash; bool result; - zend_string *var_name = zend_string_init("_SESSION", sizeof("_SESSION") - 1, 0); + zend_string *var_name = ZSTR_INIT_LITERAL("_SESSION", 0); ZVAL_NULL(&session_vars); PHP_VAR_UNSERIALIZE_INIT(var_hash); @@ -1758,7 +1758,7 @@ PHP_FUNCTION(session_set_cookie_params) } if (lifetime) { - ini_name = zend_string_init("session.cookie_lifetime", sizeof("session.cookie_lifetime") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.cookie_lifetime", 0); result = zend_alter_ini_entry(ini_name, lifetime, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); if (result == FAILURE) { @@ -1767,7 +1767,7 @@ PHP_FUNCTION(session_set_cookie_params) } } if (path) { - ini_name = zend_string_init("session.cookie_path", sizeof("session.cookie_path") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.cookie_path", 0); result = zend_alter_ini_entry(ini_name, path, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); if (result == FAILURE) { @@ -1776,7 +1776,7 @@ PHP_FUNCTION(session_set_cookie_params) } } if (domain) { - ini_name = zend_string_init("session.cookie_domain", sizeof("session.cookie_domain") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.cookie_domain", 0); result = zend_alter_ini_entry(ini_name, domain, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); if (result == FAILURE) { @@ -1785,7 +1785,7 @@ PHP_FUNCTION(session_set_cookie_params) } } if (!secure_null) { - ini_name = zend_string_init("session.cookie_secure", sizeof("session.cookie_secure") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.cookie_secure", 0); result = zend_alter_ini_entry_chars(ini_name, secure ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); if (result == FAILURE) { @@ -1794,7 +1794,7 @@ PHP_FUNCTION(session_set_cookie_params) } } if (!httponly_null) { - ini_name = zend_string_init("session.cookie_httponly", sizeof("session.cookie_httponly") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.cookie_httponly", 0); result = zend_alter_ini_entry_chars(ini_name, httponly ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); if (result == FAILURE) { @@ -1803,7 +1803,7 @@ PHP_FUNCTION(session_set_cookie_params) } } if (samesite) { - ini_name = zend_string_init("session.cookie_samesite", sizeof("session.cookie_samesite") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.cookie_samesite", 0); result = zend_alter_ini_entry(ini_name, samesite, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); if (result == FAILURE) { @@ -1865,7 +1865,7 @@ PHP_FUNCTION(session_name) RETVAL_STRING(PS(session_name)); if (name) { - ini_name = zend_string_init("session.name", sizeof("session.name") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.name", 0); zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); } @@ -1915,7 +1915,7 @@ PHP_FUNCTION(session_module_name) } PS(mod_data) = NULL; - ini_name = zend_string_init("session.save_handler", sizeof("session.save_handler") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.save_handler", 0); zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); } @@ -1939,8 +1939,8 @@ static bool can_session_handler_be_changed(void) { static inline void set_user_save_handler_ini(void) { zend_string *ini_name, *ini_val; - ini_name = zend_string_init("session.save_handler", sizeof("session.save_handler") - 1, 0); - ini_val = zend_string_init("user", sizeof("user") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.save_handler", 0); + ini_val = ZSTR_INIT_LITERAL("user", 0); PS(set_handler) = 1; zend_alter_ini_entry(ini_name, ini_val, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); PS(set_handler) = 0; @@ -2015,7 +2015,7 @@ PHP_FUNCTION(session_set_save_handler) /* Find implemented methods - SessionIdInterface (optional) */ /* First release old handlers */ SESSION_RELEASE_USER_HANDLER_OO(ps_create_sid); - zend_string *create_sid_name = zend_string_init("create_sid", strlen("create_sid"), false); + zend_string *create_sid_name = ZSTR_INIT_LITERAL("create_sid", false); if (instanceof_function(Z_OBJCE_P(obj), php_session_id_iface_entry)) { SESSION_SET_USER_HANDLER_OO(ps_create_sid, zend_string_copy(create_sid_name)); } else if (zend_hash_find_ptr(object_methods, create_sid_name)) { @@ -2029,8 +2029,8 @@ PHP_FUNCTION(session_set_save_handler) SESSION_RELEASE_USER_HANDLER_OO(ps_validate_sid); SESSION_RELEASE_USER_HANDLER_OO(ps_update_timestamp); /* Method names need to be lowercase */ - zend_string *validate_sid_name = zend_string_init("validateid", strlen("validateid"), false); - zend_string *update_timestamp_name = zend_string_init("updatetimestamp", strlen("updatetimestamp"), false); + zend_string *validate_sid_name = ZSTR_INIT_LITERAL("validateid", false); + zend_string *update_timestamp_name = ZSTR_INIT_LITERAL("updatetimestamp", false); if (instanceof_function(Z_OBJCE_P(obj), php_session_update_timestamp_iface_entry)) { /* Validate ID handler */ SESSION_SET_USER_HANDLER_OO(ps_validate_sid, zend_string_copy(validate_sid_name)); @@ -2171,7 +2171,7 @@ PHP_FUNCTION(session_save_path) RETVAL_STRING(PS(save_path)); if (name) { - ini_name = zend_string_init("session.save_path", sizeof("session.save_path") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.save_path", 0); zend_alter_ini_entry(ini_name, name, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); } @@ -2409,7 +2409,7 @@ PHP_FUNCTION(session_cache_limiter) RETVAL_STRING(PS(cache_limiter)); if (limiter) { - ini_name = zend_string_init("session.cache_limiter", sizeof("session.cache_limiter") - 1, 0); + ini_name = ZSTR_INIT_LITERAL("session.cache_limiter", 0); zend_alter_ini_entry(ini_name, limiter, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); } @@ -2439,7 +2439,7 @@ PHP_FUNCTION(session_cache_expire) RETVAL_LONG(PS(cache_expire)); if (!expires_is_null) { - zend_string *ini_name = zend_string_init("session.cache_expire", sizeof("session.cache_expire") - 1, 0); + zend_string *ini_name = ZSTR_INIT_LITERAL("session.cache_expire", 0); zend_string *ini_value = zend_long_to_str(expires); zend_alter_ini_entry(ini_name, ini_value, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zend_string_release_ex(ini_name, 0); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 44a3a3519f4..fea43f2f821 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -1753,7 +1753,7 @@ static zend_never_inline ZEND_COLD void soap_real_error_handler(int error_num, z instanceof_function(Z_OBJCE_P(error_object), soap_server_class_entry) && (service = soap_server_object_fetch(Z_OBJ_P(error_object))->service) && !service->send_errors) { - buffer = zend_string_init("Internal Error", sizeof("Internal Error")-1, 0); + buffer = ZSTR_INIT_LITERAL("Internal Error", 0); } else { buffer = zend_string_copy(message); diff --git a/ext/sodium/sodium_pwhash.c b/ext/sodium/sodium_pwhash.c index 8eaac64207f..45e206bcd94 100644 --- a/ext/sodium/sodium_pwhash.c +++ b/ext/sodium/sodium_pwhash.c @@ -171,7 +171,7 @@ static const php_password_algo sodium_algo_argon2id = { }; PHP_MINIT_FUNCTION(sodium_password_hash) /* {{{ */ { - zend_string *argon2i = zend_string_init("argon2i", strlen("argon2i"), 1); + zend_string *argon2i = ZSTR_INIT_LITERAL("argon2i", 1); if (php_password_algo_find(argon2i)) { /* Nothing to do. Core has registered these algorithms for us. */ diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 8fa3627582c..029edcdfb21 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2074,14 +2074,14 @@ PHP_METHOD(SplTempFileObject, __construct) } if (max_memory < 0) { - file_name = zend_string_init("php://memory", sizeof("php://memory")-1, 0); + file_name = ZSTR_INIT_LITERAL("php://memory", 0); } else if (ZEND_NUM_ARGS()) { file_name = zend_strpprintf(0, "php://temp/maxmemory:" ZEND_LONG_FMT, max_memory); } else { - file_name = zend_string_init("php://temp", sizeof("php://temp")-1, 0); + file_name = ZSTR_INIT_LITERAL("php://temp", 0); } intern->file_name = file_name; - intern->u.file.open_mode = zend_string_init("wb", sizeof("wb")-1, 0); + intern->u.file.open_mode = ZSTR_INIT_LITERAL("wb", 0); /* spl_filesystem_file_open() can generate E_WARNINGs which we want to promote to exceptions */ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling); diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index a3daad39519..4ff21a6f0b7 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1001,10 +1001,10 @@ static zend_object *spl_RecursiveIteratorIterator_new_ex(zend_class_entry *class if (init_prefix) { intern->prefix[0] = ZSTR_EMPTY_ALLOC(); - intern->prefix[1] = zend_string_init("| ", 2, 0); - intern->prefix[2] = zend_string_init(" ", 2, 0); - intern->prefix[3] = zend_string_init("|-", 2, 0); - intern->prefix[4] = zend_string_init("\\-", 2, 0); + intern->prefix[1] = ZSTR_INIT_LITERAL("| ", 0); + intern->prefix[2] = ZSTR_INIT_LITERAL(" ", 0); + intern->prefix[3] = ZSTR_INIT_LITERAL("|-", 0); + intern->prefix[4] = ZSTR_INIT_LITERAL("\\-", 0); intern->prefix[5] = ZSTR_EMPTY_ALLOC(); intern->postfix[0] = ZSTR_EMPTY_ALLOC(); diff --git a/ext/standard/assert.c b/ext/standard/assert.c index f5f10752fe5..0b43033dd4d 100644 --- a/ext/standard/assert.c +++ b/ext/standard/assert.c @@ -213,7 +213,7 @@ PHP_FUNCTION(assert_options) RETURN_THROWS(); } - key = zend_string_init("assert.active", sizeof("assert.active")-1, 0); + key = ZSTR_INIT_LITERAL("assert.active", 0); zend_alter_ini_entry_ex(key, value_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0); zend_string_release_ex(key, 0); zend_string_release_ex(value_str, 0); @@ -229,7 +229,7 @@ PHP_FUNCTION(assert_options) RETURN_THROWS(); } - key = zend_string_init("assert.bail", sizeof("assert.bail")-1, 0); + key = ZSTR_INIT_LITERAL("assert.bail", 0); zend_alter_ini_entry_ex(key, value_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0); zend_string_release_ex(key, 0); zend_string_release_ex(value_str, 0); @@ -245,7 +245,7 @@ PHP_FUNCTION(assert_options) RETURN_THROWS(); } - key = zend_string_init("assert.warning", sizeof("assert.warning")-1, 0); + key = ZSTR_INIT_LITERAL("assert.warning", 0); zend_alter_ini_entry_ex(key, value_str, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0); zend_string_release_ex(key, 0); zend_string_release_ex(value_str, 0); @@ -280,7 +280,7 @@ PHP_FUNCTION(assert_options) RETURN_THROWS(); } - key = zend_string_init("assert.exception", sizeof("assert.exception")-1, 0); + key = ZSTR_INIT_LITERAL("assert.exception", 0); zend_alter_ini_entry_ex(key, val, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0); zend_string_release_ex(val, 0); zend_string_release_ex(key, 0); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index f65a71a7266..1c84ddcc989 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2104,7 +2104,7 @@ PHP_FUNCTION(set_include_path) RETVAL_FALSE; } - key = zend_string_init("include_path", sizeof("include_path") - 1, 0); + key = ZSTR_INIT_LITERAL("include_path", 0); if (zend_alter_ini_entry_ex(key, new_value, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0) == FAILURE) { zend_string_release_ex(key, 0); zval_ptr_dtor_str(return_value); @@ -2185,7 +2185,7 @@ PHP_FUNCTION(ignore_user_abort) old_setting = (unsigned short)PG(ignore_user_abort); if (!arg_is_null) { - zend_string *key = zend_string_init("ignore_user_abort", sizeof("ignore_user_abort") - 1, 0); + zend_string *key = ZSTR_INIT_LITERAL("ignore_user_abort", 0); zend_alter_ini_entry_chars(key, arg ? "1" : "0", 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(key, 0); } diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index be0ee30b7d8..9ae725f7b0d 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -857,7 +857,7 @@ finish: s = ZSTR_VAL(resource->path); if (!ZSTR_LEN(resource->path)) { zend_string_release_ex(resource->path, 0); - resource->path = zend_string_init("/", 1, 0); + resource->path = ZSTR_INIT_LITERAL("/", 0); s = ZSTR_VAL(resource->path); } else { *s = '/'; diff --git a/ext/standard/password.c b/ext/standard/password.c index 30e524dafbb..af1b68af108 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -497,14 +497,14 @@ static const php_password_algo* php_password_algo_find_zval(zend_string *arg_str #else case 2: { - zend_string *n = zend_string_init("argon2i", sizeof("argon2i")-1, 0); + zend_string *n = ZSTR_INIT_LITERAL("argon2i", 0); const php_password_algo* ret = php_password_algo_find(n); zend_string_release(n); return ret; } case 3: { - zend_string *n = zend_string_init("argon2id", sizeof("argon2id")-1, 0); + zend_string *n = ZSTR_INIT_LITERAL("argon2id", 0); const php_password_algo* ret = php_password_algo_find(n); zend_string_release(n); return ret; diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 2c4d5d3d263..adfec58e8db 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -112,7 +112,7 @@ static void userfilter_dtor(php_stream_filter *thisfilter) return; } - zend_string *func_name = zend_string_init("onclose", sizeof("onclose")-1, 0); + zend_string *func_name = ZSTR_INIT_LITERAL("onclose", 0); zend_call_method_if_exists(Z_OBJ_P(obj), func_name, &retval, 0, NULL); zend_string_release(func_name); @@ -313,7 +313,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, } /* invoke the constructor */ - zend_string *func_name = zend_string_init("oncreate", sizeof("oncreate")-1, 0); + zend_string *func_name = ZSTR_INIT_LITERAL("oncreate", 0); zend_call_method_if_exists(Z_OBJ(obj), func_name, &retval, 0, NULL); zend_string_release(func_name); diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 8dbe6b27a11..7f3d1e0e421 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -359,7 +359,7 @@ PHP_METHOD(XSLTProcessor, importStylesheet) intern = Z_XSL_P(id); - member = zend_string_init("cloneDocument", sizeof("cloneDocument")-1, 0); + member = ZSTR_INIT_LITERAL("cloneDocument", 0); cloneDocu = zend_std_read_property(Z_OBJ_P(id), member, BP_VAR_IS, NULL, &rv); if (Z_TYPE_P(cloneDocu) != IS_NULL) { convert_to_long(cloneDocu); @@ -460,7 +460,7 @@ static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStyl ctxt = xsltNewTransformContext(style, doc); ctxt->_private = (void *) intern; - member = zend_string_init("doXInclude", sizeof("doXInclude")-1, 0); + member = ZSTR_INIT_LITERAL("doXInclude", 0); doXInclude = zend_std_read_property(Z_OBJ_P(id), member, BP_VAR_IS, NULL, &rv); if (Z_TYPE_P(doXInclude) != IS_NULL) { convert_to_long(doXInclude); diff --git a/main/SAPI.c b/main/SAPI.c index e71cba0fb1d..2e697f97796 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -801,7 +801,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg) * to disable compression altogether. This contributes to making scripts * portable between setups that have and don't have zlib compression * enabled globally. See req #44164 */ - zend_string *key = zend_string_init("zlib.output_compression", sizeof("zlib.output_compression")-1, 0); + zend_string *key = ZSTR_INIT_LITERAL("zlib.output_compression", 0); zend_alter_ini_entry_chars(key, "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); zend_string_release_ex(key, 0); diff --git a/main/main.c b/main/main.c index d9defc974cc..022f26bd5f4 100644 --- a/main/main.c +++ b/main/main.c @@ -1492,7 +1492,7 @@ PHP_FUNCTION(set_time_limit) new_timeout_strlen = zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout); - key = zend_string_init("max_execution_time", sizeof("max_execution_time")-1, 0); + key = ZSTR_INIT_LITERAL("max_execution_time", 0); if (zend_alter_ini_entry_chars_ex(key, new_timeout_str, new_timeout_strlen, PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0) == SUCCESS) { RETVAL_TRUE; } else { diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index 514d60d176e..e78cbeab110 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -171,7 +171,7 @@ int fpm_status_handle_request(void) /* {{{ */ fpm_request_executing(); /* full status ? */ - _GET_str = zend_string_init("_GET", sizeof("_GET")-1, 0); + _GET_str = ZSTR_INIT_LITERAL("_GET", 0); full = (fpm_php_get_string_from_table(_GET_str, "full") != NULL); short_syntax = short_post = NULL; full_separator = full_pre = full_syntax = full_post = NULL; diff --git a/sapi/fuzzer/fuzzer-function-jit.c b/sapi/fuzzer/fuzzer-function-jit.c index c637bcfa608..bd99299984a 100644 --- a/sapi/fuzzer/fuzzer-function-jit.c +++ b/sapi/fuzzer/fuzzer-function-jit.c @@ -23,7 +23,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } - zend_string *jit_option = zend_string_init("opcache.jit", sizeof("opcache.jit") - 1, 1); + zend_string *jit_option = ZSTR_INIT_LITERAL("opcache.jit", 1); /* First run without JIT to determine whether we bail out. We should not run JITed code if * we bail out here, as the JIT code may loop infinitely. */ diff --git a/sapi/fuzzer/fuzzer-tracing-jit.c b/sapi/fuzzer/fuzzer-tracing-jit.c index 585bf55304a..7113bf07969 100644 --- a/sapi/fuzzer/fuzzer-tracing-jit.c +++ b/sapi/fuzzer/fuzzer-tracing-jit.c @@ -23,7 +23,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { return 0; } - zend_string *jit_option = zend_string_init("opcache.jit", sizeof("opcache.jit") - 1, 1); + zend_string *jit_option = ZSTR_INIT_LITERAL("opcache.jit", 1); /* First run without JIT to determine whether we bail out. We should not run JITed code if * we bail out here, as the JIT code may loop infinitely. */ diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 79fae63507c..46ad97f2bf3 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -702,7 +702,7 @@ static void lsapi_clean_shutdown(void) setitimer(ITIMER_PROF, &tmv, NULL); #if PHP_MAJOR_VERSION >= 7 - key = zend_string_init("error_reporting", 15, 1); + key = ZSTR_INIT_LITERAL("error_reporting", 1); zend_alter_ini_entry_chars_ex(key, "0", 1, PHP_INI_SYSTEM, PHP_INI_STAGE_SHUTDOWN, 1); zend_string_release(key);