summaryrefslogtreecommitdiff
path: root/ext/zip
diff options
context:
space:
mode:
Diffstat (limited to 'ext/zip')
-rw-r--r--ext/zip/php_zip.c36
-rw-r--r--ext/zip/zip_stream.c11
2 files changed, 23 insertions, 24 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index a9db166c83..df6ea03dab 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -173,12 +173,11 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
char *file_dirname_fullpath;
char file_dirname[MAXPATHLEN];
size_t dir_len;
- char *file_basename;
- size_t file_basename_len;
int is_dir_only = 0;
char *path_cleaned;
size_t path_cleaned_len;
cwd_state new_state;
+ zend_string *file_basename;
new_state.cwd = CWD_STATE_ALLOC(1);
new_state.cwd[0] = '\0';
@@ -212,11 +211,11 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
len = spprintf(&file_dirname_fullpath, 0, "%s/%s", dest, file_dirname);
}
- php_basename(path_cleaned, path_cleaned_len, NULL, 0, &file_basename, (size_t *)&file_basename_len TSRMLS_CC);
+ file_basename = php_basename(path_cleaned, path_cleaned_len, NULL, 0 TSRMLS_CC);
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname_fullpath)) {
efree(file_dirname_fullpath);
- efree(file_basename);
+ STR_RELEASE(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -240,7 +239,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
if (!ret) {
efree(file_dirname_fullpath);
if (!is_dir_only) {
- efree(file_basename);
+ STR_RELEASE(file_basename);
CWD_STATE_FREE(new_state.cwd);
}
return 0;
@@ -254,16 +253,16 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
return 1;
}
- len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, file_basename);
+ len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, file_basename->val);
if (!len) {
efree(file_dirname_fullpath);
- efree(file_basename);
+ STR_RELEASE(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
} else if (len > MAXPATHLEN) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Full extraction path exceed MAXPATHLEN (%i)", MAXPATHLEN);
efree(file_dirname_fullpath);
- efree(file_basename);
+ STR_RELEASE(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -275,7 +274,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
if (ZIP_OPENBASEDIR_CHECKPATH(fullpath)) {
efree(fullpath);
efree(file_dirname_fullpath);
- efree(file_basename);
+ STR_RELEASE(file_basename);
CWD_STATE_FREE(new_state.cwd);
return 0;
}
@@ -309,7 +308,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
done:
efree(fullpath);
- efree(file_basename);
+ STR_RELEASE(file_basename);
efree(file_dirname_fullpath);
CWD_STATE_FREE(new_state.cwd);
@@ -438,7 +437,7 @@ static int php_zip_parse_options(zval *options, long *remove_all_path,
#define RETURN_SB(sb) \
{ \
array_init(return_value); \
- add_ascii_assoc_string(return_value, "name", (char *)(sb)->name, 1); \
+ add_ascii_assoc_string(return_value, "name", (char *)(sb)->name); \
add_ascii_assoc_long(return_value, "index", (long) (sb)->index); \
add_ascii_assoc_long(return_value, "crc", (long) (sb)->crc); \
add_ascii_assoc_long(return_value, "size", (long) (sb)->size); \
@@ -621,7 +620,7 @@ int php_zip_glob(char *pattern, int pattern_len, long flags, zval *return_value
continue;
}
}
- add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip, 1);
+ add_next_index_string(return_value, globbuf.gl_pathv[n]+cwd_skip);
}
globfree(&globbuf);
@@ -723,7 +722,7 @@ int php_zip_pcre(char *regexp, int regexp_len, char *path, int path_len, zval *r
continue;
}
- add_next_index_string(return_value, fullpath, 1);
+ add_next_index_string(return_value, fullpath);
efree(namelist[i]);
}
efree(namelist);
@@ -1773,13 +1772,14 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
char *file_stripped, *entry_name;
size_t entry_name_len, file_stripped_len;
char entry_name_buf[MAXPATHLEN];
- char *basename = NULL;
+ zend_string *basename = NULL;
if (zend_hash_index_find(Z_ARRVAL_P(return_value), i, (void **) &zval_file) == SUCCESS) {
if (remove_all_path) {
- php_basename(Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), NULL, 0,
- &basename, (size_t *)&file_stripped_len TSRMLS_CC);
- file_stripped = basename;
+ basename = php_basename(Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), NULL, 0,
+ &basename TSRMLS_CC);
+ file_stripped = basename->val;
+ file_stripped_len = basename->len;
} else if (remove_path && strstr(Z_STRVAL_PP(zval_file), remove_path) != NULL) {
file_stripped = Z_STRVAL_PP(zval_file) + remove_path_len + 1;
file_stripped_len = Z_STRLEN_PP(zval_file) - remove_path_len - 1;
@@ -1804,7 +1804,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
entry_name_len = Z_STRLEN_PP(zval_file);
}
if (basename) {
- efree(basename);
+ STR_RELEASE(basename);
basename = NULL;
}
if (php_zip_add_file(intern, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file),
diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c
index 8d02d89637..956f066064 100644
--- a/ext/zip/zip_stream.c
+++ b/ext/zip/zip_stream.c
@@ -118,13 +118,12 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
struct zip_stat sb;
const char *path = stream->orig_path;
int path_len = strlen(stream->orig_path);
- char *file_basename;
- size_t file_basename_len;
char file_dirname[MAXPATHLEN];
struct zip *za;
char *fragment;
int fragment_len;
int err;
+ zend_string *file_basename;
fragment = strchr(path, '#');
if (!fragment) {
@@ -149,11 +148,11 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
memcpy(file_dirname, path, path_len - fragment_len);
file_dirname[path_len - fragment_len] = '\0';
- php_basename((char *)path, path_len - fragment_len, NULL, 0, &file_basename, &file_basename_len TSRMLS_CC);
+ file_basename = php_basename((char *)path, path_len - fragment_len, NULL, 0 TSRMLS_CC);
fragment++;
if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) {
- efree(file_basename);
+ STR_RELEASE(file_basename);
return -1;
}
@@ -161,7 +160,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
if (za) {
memset(ssb, 0, sizeof(php_stream_statbuf));
if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) {
- efree(file_basename);
+ STR_RELEASE(file_basename);
return -1;
}
zip_close(za);
@@ -185,7 +184,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb TSRMLS_D
#endif
ssb->sb.st_ino = -1;
}
- efree(file_basename);
+ STR_RELEASE(file_basename);
return 0;
}
/* }}} */