Replace uses of php_dirname() with zend_dirname() (#15393)

This removes some needs to include the php_string.h header
This commit is contained in:
Gina Peter Banyard 2024-08-14 12:35:47 +01:00 committed by GitHub
parent 2054c3d238
commit 02177848e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 7 additions and 8 deletions

View file

@ -23,7 +23,7 @@
#include "ext/standard/php_filestat.h" #include "ext/standard/php_filestat.h"
#include "ext/standard/flock_compat.h" #include "ext/standard/flock_compat.h"
#include "ext/standard/scanf.h" #include "ext/standard/scanf.h"
#include "ext/standard/php_string.h" #include "ext/standard/php_string.h" /* For php_basename() */
#include "zend_attributes.h" #include "zend_attributes.h"
#include "zend_exceptions.h" #include "zend_exceptions.h"
#include "zend_interfaces.h" #include "zend_interfaces.h"
@ -1362,7 +1362,7 @@ PHP_METHOD(SplFileInfo, getPathInfo)
path = spl_filesystem_object_get_pathname(intern); path = spl_filesystem_object_get_pathname(intern);
if (path && ZSTR_LEN(path)) { if (path && ZSTR_LEN(path)) {
zend_string *dpath = zend_string_init(ZSTR_VAL(path), ZSTR_LEN(path), 0); zend_string *dpath = zend_string_init(ZSTR_VAL(path), ZSTR_LEN(path), 0);
ZSTR_LEN(dpath) = php_dirname(ZSTR_VAL(dpath), ZSTR_LEN(path)); ZSTR_LEN(dpath) = zend_dirname(ZSTR_VAL(dpath), ZSTR_LEN(path));
spl_filesystem_object_create_info(dpath, ce, return_value); spl_filesystem_object_create_info(dpath, ce, return_value);
zend_string_release(dpath); zend_string_release(dpath);
} }

View file

@ -99,8 +99,9 @@ PHP_FUNCTION(linkinfo)
Z_PARAM_PATH(link, link_len) Z_PARAM_PATH(link, link_len)
ZEND_PARSE_PARAMETERS_END(); ZEND_PARSE_PARAMETERS_END();
// TODO Check for empty string
dirname = estrndup(link, link_len); dirname = estrndup(link, link_len);
php_dirname(dirname, link_len); zend_dirname(dirname, link_len);
if (php_check_open_basedir(dirname)) { if (php_check_open_basedir(dirname)) {
efree(dirname); efree(dirname);
@ -141,7 +142,7 @@ PHP_FUNCTION(symlink)
} }
memcpy(dirname, source_p, sizeof(source_p)); memcpy(dirname, source_p, sizeof(source_p));
len = php_dirname(dirname, strlen(dirname)); len = zend_dirname(dirname, strlen(dirname));
if (!expand_filepath_ex(topath, dest_p, dirname, len)) { if (!expand_filepath_ex(topath, dest_p, dirname, len)) {
php_error_docref(NULL, E_WARNING, "No such file or directory"); php_error_docref(NULL, E_WARNING, "No such file or directory");

View file

@ -24,7 +24,6 @@
#include "ext/standard/info.h" #include "ext/standard/info.h"
#include "php_xmlwriter.h" #include "php_xmlwriter.h"
#include "php_xmlwriter_arginfo.h" #include "php_xmlwriter_arginfo.h"
#include "ext/standard/php_string.h" /* For php_dirname() */
static zend_class_entry *xmlwriter_class_entry_ce; static zend_class_entry *xmlwriter_class_entry_ce;
@ -158,7 +157,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
} }
memcpy(file_dirname, source, strlen(source)); memcpy(file_dirname, source, strlen(source));
dir_len = php_dirname(file_dirname, strlen(source)); dir_len = zend_dirname(file_dirname, strlen(source));
if (dir_len > 0) { if (dir_len > 0) {
zend_stat_t buf = {0}; zend_stat_t buf = {0};

View file

@ -171,7 +171,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s
is_dir_only = 1; is_dir_only = 1;
} else { } else {
memcpy(file_dirname, path_cleaned, path_cleaned_len); memcpy(file_dirname, path_cleaned, path_cleaned_len);
dir_len = php_dirname(file_dirname, path_cleaned_len); dir_len = zend_dirname(file_dirname, path_cleaned_len);
if (!dir_len || (dir_len == 1 && file_dirname[0] == '.')) { if (!dir_len || (dir_len == 1 && file_dirname[0] == '.')) {
len = spprintf(&file_dirname_fullpath, 0, "%s", dest); len = spprintf(&file_dirname_fullpath, 0, "%s", dest);

View file

@ -95,7 +95,6 @@
#include "zend_smart_str.h" #include "zend_smart_str.h"
#include "ext/standard/html.h" #include "ext/standard/html.h"
#include "ext/standard/url.h" /* for php_raw_url_decode() */ #include "ext/standard/url.h" /* for php_raw_url_decode() */
#include "ext/standard/php_string.h" /* for php_dirname() */
#include "ext/date/php_date.h" /* for php_format_date() */ #include "ext/date/php_date.h" /* for php_format_date() */
#include "php_network.h" #include "php_network.h"