From e95b0bb94922860b52052db04775a7ab48076197 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 15 Feb 2025 15:56:29 +0100 Subject: [PATCH] Fix Windows build for GH-17814 and add extension dependency --- ext/phar/tests/gh17808.phpt | 1 + ext/phar/util.c | 38 +++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ext/phar/tests/gh17808.phpt b/ext/phar/tests/gh17808.phpt index 28cb9a2e22792..03e54ff264bfa 100644 --- a/ext/phar/tests/gh17808.phpt +++ b/ext/phar/tests/gh17808.phpt @@ -2,6 +2,7 @@ GH-17808 (PharFileInfo refcount bug) --EXTENSIONS-- phar +zlib --FILE-- is_persistent) { @@ -1245,16 +1254,12 @@ phar_entry_info *phar_get_entry_info(phar_archive_data *phar, const char *path, * valid pre-existing empty directory entries */ // TODO: convert this to use zend_string too -phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, const char *path, size_t path_len, char dir, char **error, int security) /* {{{ */ +static phar_entry_info *phar_get_entry_info_dir_ex(phar_archive_data *phar, const char *path, size_t path_len, char dir, char **error, int security) /* {{{ */ { const char *pcr_error; phar_entry_info *entry; int is_dir; -#ifdef PHP_WIN32 - phar_unixify_path_separators(path, path_len); -#endif - is_dir = (path_len && (path[path_len - 1] == '/')) ? 1 : 0; if (error) { @@ -1401,6 +1406,19 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, const char *pa } /* }}} */ +phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, const char *path, size_t path_len, char dir, char **error, int security) +{ +#ifdef PHP_WIN32 + char *path_dup = estrndup(path, path_len); + phar_unixify_path_separators(path_dup, path_len); + phar_entry_info *ret = phar_get_entry_info_dir_ex(phar, path_dup, path_len, dir, error, security); + efree(path_dup); + return ret; +#else + return phar_get_entry_info_dir_ex(phar, path, path_len, dir, error, security); +#endif +} + static const char hexChars[] = "0123456789ABCDEF"; static int phar_hex_str(const char *digest, size_t digest_len, char **signature) /* {{{ */