Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "ext/standard/php_filestat.h"
#include "ext/standard/flock_compat.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_exceptions.h"
#include "zend_interfaces.h"
Expand Down Expand Up @@ -1362,7 +1362,7 @@ PHP_METHOD(SplFileInfo, getPathInfo)
path = spl_filesystem_object_get_pathname(intern);
if (path && ZSTR_LEN(path)) {
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);
zend_string_release(dpath);
}
Expand Down
5 changes: 3 additions & 2 deletions ext/standard/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ PHP_FUNCTION(linkinfo)
Z_PARAM_PATH(link, link_len)
ZEND_PARSE_PARAMETERS_END();

// TODO Check for empty string
dirname = estrndup(link, link_len);
php_dirname(dirname, link_len);
zend_dirname(dirname, link_len);

if (php_check_open_basedir(dirname)) {
efree(dirname);
Expand Down Expand Up @@ -141,7 +142,7 @@ PHP_FUNCTION(symlink)
}

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)) {
php_error_docref(NULL, E_WARNING, "No such file or directory");
Expand Down
3 changes: 1 addition & 2 deletions ext/xmlwriter/php_xmlwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "ext/standard/info.h"
#include "php_xmlwriter.h"
#include "php_xmlwriter_arginfo.h"
#include "ext/standard/php_string.h" /* For php_dirname() */

static zend_class_entry *xmlwriter_class_entry_ce;

Expand Down Expand Up @@ -158,7 +157,7 @@ static char *_xmlwriter_get_valid_file_path(char *source, char *resolved_path, i
}

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) {
zend_stat_t buf = {0};
Expand Down
2 changes: 1 addition & 1 deletion ext/zip/php_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s
is_dir_only = 1;
} else {
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] == '.')) {
len = spprintf(&file_dirname_fullpath, 0, "%s", dest);
Expand Down
1 change: 0 additions & 1 deletion sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
#include "zend_smart_str.h"
#include "ext/standard/html.h"
#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 "php_network.h"

Expand Down
Loading