diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 7212aa6b141f1..b153472c4d17a 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1071,26 +1071,26 @@ PHP_FUNCTION(getopt) /* Add this option / argument pair to the result hash. */ optname_len = strlen(optname); - if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, NULL, NULL, 0) == IS_LONG) { + zend_long opt_name_as_long = 0; + if (!(optname_len > 1 && optname[0] == '0') && is_numeric_string(optname, optname_len, &opt_name_as_long, NULL, 0) == IS_LONG) { /* numeric string */ - int optname_int = atoi(optname); - if ((args = zend_hash_index_find(Z_ARRVAL_P(return_value), optname_int)) != NULL) { + if ((args = zend_hash_index_find(Z_ARRVAL_P(return_value), opt_name_as_long)) != NULL) { if (Z_TYPE_P(args) != IS_ARRAY) { convert_to_array(args); } zend_hash_next_index_insert(Z_ARRVAL_P(args), &val); } else { - zend_hash_index_update(Z_ARRVAL_P(return_value), optname_int, &val); + zend_hash_index_update(Z_ARRVAL_P(return_value), opt_name_as_long, &val); } } else { /* other strings */ - if ((args = zend_hash_str_find(Z_ARRVAL_P(return_value), optname, strlen(optname))) != NULL) { + if ((args = zend_hash_str_find(Z_ARRVAL_P(return_value), optname, optname_len)) != NULL) { if (Z_TYPE_P(args) != IS_ARRAY) { convert_to_array(args); } zend_hash_next_index_insert(Z_ARRVAL_P(args), &val); } else { - zend_hash_str_add(Z_ARRVAL_P(return_value), optname, strlen(optname), &val); + zend_hash_str_add(Z_ARRVAL_P(return_value), optname, optname_len, &val); } } @@ -1921,8 +1921,8 @@ PHP_FUNCTION(ini_get) /* {{{ Get all configuration options */ PHP_FUNCTION(ini_get_all) { - char *extname = NULL; - size_t extname_len = 0, module_number = 0; + zend_string *extname = NULL; + size_t module_number = 0; zend_module_entry *module; bool details = 1; zend_string *key; @@ -1931,15 +1931,15 @@ PHP_FUNCTION(ini_get_all) ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STRING_OR_NULL(extname, extname_len) + Z_PARAM_STR_OR_NULL(extname) Z_PARAM_BOOL(details) ZEND_PARSE_PARAMETERS_END(); zend_ini_sort_entries(); if (extname) { - if ((module = zend_hash_str_find_ptr(&module_registry, extname, extname_len)) == NULL) { - php_error_docref(NULL, E_WARNING, "Extension \"%s\" cannot be found", extname); + if ((module = zend_hash_find_ptr(&module_registry, extname)) == NULL) { + php_error_docref(NULL, E_WARNING, "Extension \"%s\" cannot be found", ZSTR_VAL(extname)); RETURN_FALSE; } module_number = module->module_number; @@ -2088,17 +2088,15 @@ PHP_FUNCTION(set_include_path) /* {{{ Get the current include_path configuration option */ PHP_FUNCTION(get_include_path) { - char *str; - ZEND_PARSE_PARAMETERS_NONE(); - str = zend_ini_string("include_path", sizeof("include_path") - 1, 0); + zend_string *str = zend_ini_str("include_path", sizeof("include_path") - 1, 0); if (str == NULL) { RETURN_FALSE; } - RETURN_STRING(str); + RETURN_STR_COPY(str); } /* }}} */ @@ -2331,18 +2329,17 @@ PHP_FUNCTION(unregister_tick_function) /* {{{ Check if file was created by rfc1867 upload */ PHP_FUNCTION(is_uploaded_file) { - char *path; - size_t path_len; + zend_string *path; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_PATH(path, path_len) + Z_PARAM_PATH_STR(path) ZEND_PARSE_PARAMETERS_END(); if (!SG(rfc1867_uploaded_files)) { RETURN_FALSE; } - if (zend_hash_str_exists(SG(rfc1867_uploaded_files), path, path_len)) { + if (zend_hash_exists(SG(rfc1867_uploaded_files), path)) { RETURN_TRUE; } else { RETURN_FALSE; @@ -2353,8 +2350,7 @@ PHP_FUNCTION(is_uploaded_file) /* {{{ Move a file if and only if it was created by an upload */ PHP_FUNCTION(move_uploaded_file) { - char *path, *new_path; - size_t path_len, new_path_len; + zend_string *path, *new_path; bool successful = 0; #ifndef PHP_WIN32 @@ -2362,43 +2358,43 @@ PHP_FUNCTION(move_uploaded_file) #endif ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STRING(path, path_len) - Z_PARAM_PATH(new_path, new_path_len) + Z_PARAM_PATH_STR(path) + Z_PARAM_PATH_STR(new_path) ZEND_PARSE_PARAMETERS_END(); if (!SG(rfc1867_uploaded_files)) { RETURN_FALSE; } - if (!zend_hash_str_exists(SG(rfc1867_uploaded_files), path, path_len)) { + if (!zend_hash_exists(SG(rfc1867_uploaded_files), path)) { RETURN_FALSE; } - if (php_check_open_basedir(new_path)) { + if (php_check_open_basedir(ZSTR_VAL(new_path))) { RETURN_FALSE; } - if (VCWD_RENAME(path, new_path) == 0) { + if (VCWD_RENAME(ZSTR_VAL(path), ZSTR_VAL(new_path)) == 0) { successful = 1; #ifndef PHP_WIN32 oldmask = umask(077); umask(oldmask); - ret = VCWD_CHMOD(new_path, 0666 & ~oldmask); + ret = VCWD_CHMOD(ZSTR_VAL(new_path), 0666 & ~oldmask); if (ret == -1) { php_error_docref(NULL, E_WARNING, "%s", strerror(errno)); } #endif - } else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR) == SUCCESS) { - VCWD_UNLINK(path); + } else if (php_copy_file_ex(ZSTR_VAL(path), ZSTR_VAL(new_path), STREAM_DISABLE_OPEN_BASEDIR) == SUCCESS) { + VCWD_UNLINK(ZSTR_VAL(path)); successful = 1; } if (successful) { - zend_hash_str_del(SG(rfc1867_uploaded_files), path, path_len); + zend_hash_del(SG(rfc1867_uploaded_files), path); } else { - php_error_docref(NULL, E_WARNING, "Unable to move \"%s\" to \"%s\"", path, new_path); + php_error_docref(NULL, E_WARNING, "Unable to move \"%s\" to \"%s\"", ZSTR_VAL(path), ZSTR_VAL(new_path)); } RETURN_BOOL(successful);