summaryrefslogtreecommitdiffstats
path: root/upstream.patch
diff options
context:
space:
mode:
Diffstat (limited to 'upstream.patch')
-rw-r--r--upstream.patch438
1 files changed, 438 insertions, 0 deletions
diff --git a/upstream.patch b/upstream.patch
new file mode 100644
index 0000000..df227ac
--- /dev/null
+++ b/upstream.patch
@@ -0,0 +1,438 @@
+diff --git a/php5/php_zip.c b/php5/php_zip.c
+index 53427d9..f466748 100644
+--- a/php5/php_zip.c
++++ b/php5/php_zip.c
+@@ -154,7 +154,7 @@ static char * php_zip_make_relative_path(char *path, int path_len) /* {{{ */
+ #endif
+
+ /* {{{ php_zip_extract_file */
+-static int php_zip_extract_file(struct zip * za, char *dest, char *file, int file_len TSRMLS_DC)
++static int php_zip_extract_file(struct zip * za, char *dest, const char *file, int file_len, zip_int64_t idx TSRMLS_DC)
+ {
+ php_stream_statbuf ssb;
+ struct zip_file *zf;
+@@ -173,6 +173,12 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
+ size_t path_cleaned_len;
+ cwd_state new_state;
+
++ if (idx <0) {
++ idx = zip_name_locate(za, file, 0);
++ if (idx < 0) {
++ return 0;
++ }
++ }
+ new_state.cwd = CWD_STATE_ALLOC(1);
+ new_state.cwd[0] = '\0';
+ new_state.cwd_length = 0;
+@@ -188,7 +194,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
+ }
+ path_cleaned_len = strlen(path_cleaned);
+
+- if (path_cleaned_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb) != 0) {
++ if (path_cleaned_len >= MAXPATHLEN || zip_stat_index(za, idx, 0, &sb) != 0) {
+ CWD_STATE_FREE(new_state.cwd);
+ return 0;
+ }
+@@ -264,7 +270,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
+ return 0;
+ }
+
+- zf = zip_fopen(za, file, 0);
++ zf = zip_fopen_index(za, idx, 0);
+ if (zf == NULL) {
+ n = -1;
+ goto done;
+@@ -3164,7 +3170,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+
+ switch (Z_TYPE_P(zval_files)) {
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files) TSRMLS_CC)) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files), -1 TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -3179,7 +3185,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+ case IS_LONG:
+ break;
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file) TSRMLS_CC)) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_PP(zval_file), Z_STRLEN_PP(zval_file), -1 TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -3202,8 +3208,8 @@ static ZIPARCHIVE_METHOD(extractTo)
+ }
+
+ for (i = 0; i < filecount; i++) {
+- char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED);
+- if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file) TSRMLS_CC)) {
++ const char *file = zip_get_name(intern, i, ZIP_FL_UNCHANGED);
++ if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file), i TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+ }
+diff --git a/php7/php_zip.c b/php7/php_zip.c
+index a13b127..f4188b7 100644
+--- a/php7/php_zip.c
++++ b/php7/php_zip.c
+@@ -137,7 +137,7 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */
+ # define CWD_STATE_FREE(s) efree(s)
+
+ /* {{{ php_zip_extract_file */
+-static int php_zip_extract_file(struct zip * za, char *dest, char *file, int file_len)
++static int php_zip_extract_file(struct zip * za, char *dest, const char *file, size_t file_len, zip_int64_t idx)
+ {
+ php_stream_statbuf ssb;
+ struct zip_file *zf;
+@@ -155,6 +155,12 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
+ cwd_state new_state;
+ zend_string *file_basename;
+
++ if (idx <0) {
++ idx = zip_name_locate(za, file, 0);
++ if (idx < 0) {
++ return 0;
++ }
++ }
+ new_state.cwd = CWD_STATE_ALLOC(1);
+ new_state.cwd[0] = '\0';
+ new_state.cwd_length = 0;
+@@ -170,7 +176,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
+ }
+ path_cleaned_len = strlen(path_cleaned);
+
+- if (path_cleaned_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb) != 0) {
++ if (path_cleaned_len >= MAXPATHLEN || zip_stat_index(za, idx, 0, &sb) != 0) {
+ CWD_STATE_FREE(new_state.cwd);
+ return 0;
+ }
+@@ -245,7 +251,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, int fil
+ return 0;
+ }
+
+- zf = zip_fopen(za, file, 0);
++ zf = zip_fopen_index(za, idx, 0);
+ if (zf == NULL) {
+ n = -1;
+ goto done;
+@@ -3062,7 +3068,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+
+ switch (Z_TYPE_P(zval_files)) {
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -3079,7 +3085,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+ case IS_LONG:
+ break;
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -3102,8 +3108,8 @@ static ZIPARCHIVE_METHOD(extractTo)
+ }
+
+ for (i = 0; i < filecount; i++) {
+- char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED);
+- if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file))) {
++ const char *file = zip_get_name(intern, i, ZIP_FL_UNCHANGED);
++ if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file), i)) {
+ RETURN_FALSE;
+ }
+ }
+diff --git a/php73/php_zip.c b/php73/php_zip.c
+index 4b44fca..a6e1938 100644
+--- a/php73/php_zip.c
++++ b/php73/php_zip.c
+@@ -137,7 +137,7 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */
+ # define CWD_STATE_FREE(s) efree(s)
+
+ /* {{{ php_zip_extract_file */
+-static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t file_len)
++static int php_zip_extract_file(struct zip * za, char *dest, const char *file, size_t file_len, zip_int64_t idx)
+ {
+ php_stream_statbuf ssb;
+ struct zip_file *zf;
+@@ -155,6 +155,12 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ cwd_state new_state;
+ zend_string *file_basename;
+
++ if (idx <0) {
++ idx = zip_name_locate(za, file, 0);
++ if (idx < 0) {
++ return 0;
++ }
++ }
+ new_state.cwd = CWD_STATE_ALLOC(1);
+ new_state.cwd[0] = '\0';
+ new_state.cwd_length = 0;
+@@ -170,7 +176,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ }
+ path_cleaned_len = strlen(path_cleaned);
+
+- if (path_cleaned_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb) != 0) {
++ if (path_cleaned_len >= MAXPATHLEN || zip_stat_index(za, idx, 0, &sb) != 0) {
+ CWD_STATE_FREE(new_state.cwd);
+ return 0;
+ }
+@@ -245,7 +251,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ return 0;
+ }
+
+- zf = zip_fopen(za, file, 0);
++ zf = zip_fopen_index(za, idx, 0);
+ if (zf == NULL) {
+ n = -1;
+ goto done;
+@@ -3065,7 +3071,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+
+ switch (Z_TYPE_P(zval_files)) {
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -3081,7 +3087,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+ case IS_LONG:
+ break;
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -3104,8 +3110,8 @@ static ZIPARCHIVE_METHOD(extractTo)
+ }
+
+ for (i = 0; i < filecount; i++) {
+- char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED);
+- if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file))) {
++ const char *file = zip_get_name(intern, i, ZIP_FL_UNCHANGED);
++ if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file), i)) {
+ RETURN_FALSE;
+ }
+ }
+diff --git a/php74/php_zip.c b/php74/php_zip.c
+index 36d8a0f..ebdda24 100644
+--- a/php74/php_zip.c
++++ b/php74/php_zip.c
+@@ -133,7 +133,7 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */
+ # define CWD_STATE_FREE(s) efree(s)
+
+ /* {{{ php_zip_extract_file */
+-static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t file_len)
++static int php_zip_extract_file(struct zip * za, char *dest, const char *file, size_t file_len, zip_int64_t idx)
+ {
+ php_stream_statbuf ssb;
+ struct zip_file *zf;
+@@ -151,6 +151,12 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ cwd_state new_state;
+ zend_string *file_basename;
+
++ if (idx <0) {
++ idx = zip_name_locate(za, file, 0);
++ if (idx < 0) {
++ return 0;
++ }
++ }
+ new_state.cwd = CWD_STATE_ALLOC(1);
+ new_state.cwd[0] = '\0';
+ new_state.cwd_length = 0;
+@@ -166,7 +172,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ }
+ path_cleaned_len = strlen(path_cleaned);
+
+- if (path_cleaned_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb) != 0) {
++ if (path_cleaned_len >= MAXPATHLEN || zip_stat_index(za, idx, 0, &sb) != 0) {
+ CWD_STATE_FREE(new_state.cwd);
+ return 0;
+ }
+@@ -241,7 +247,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ return 0;
+ }
+
+- zf = zip_fopen(za, file, 0);
++ zf = zip_fopen_index(za, idx, 0);
+ if (zf == NULL) {
+ n = -1;
+ goto done;
+@@ -2922,7 +2928,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+
+ switch (Z_TYPE_P(zval_files)) {
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_files), Z_STRLEN_P(zval_files), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -2938,7 +2944,7 @@ static ZIPARCHIVE_METHOD(extractTo)
+ case IS_LONG:
+ break;
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -2961,8 +2967,8 @@ static ZIPARCHIVE_METHOD(extractTo)
+ }
+
+ for (i = 0; i < filecount; i++) {
+- char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED);
+- if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file))) {
++ const char *file = zip_get_name(intern, i, ZIP_FL_UNCHANGED);
++ if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file), i)) {
+ RETURN_FALSE;
+ }
+ }
+diff --git a/php8/php_zip.c b/php8/php_zip.c
+index 9de2d68..f2947b5 100644
+--- a/php8/php_zip.c
++++ b/php8/php_zip.c
+@@ -121,7 +121,7 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */
+ # define CWD_STATE_FREE(s) efree(s)
+
+ /* {{{ php_zip_extract_file */
+-static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t file_len)
++static int php_zip_extract_file(struct zip * za, char *dest, const char *file, size_t file_len, zip_int64_t idx)
+ {
+ php_stream_statbuf ssb;
+ struct zip_file *zf;
+@@ -139,6 +139,12 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ cwd_state new_state;
+ zend_string *file_basename;
+
++ if (idx <0) {
++ idx = zip_name_locate(za, file, 0);
++ if (idx < 0) {
++ return 0;
++ }
++ }
+ new_state.cwd = CWD_STATE_ALLOC(1);
+ new_state.cwd[0] = '\0';
+ new_state.cwd_length = 0;
+@@ -154,7 +160,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ }
+ path_cleaned_len = strlen(path_cleaned);
+
+- if (path_cleaned_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb) != 0) {
++ if (path_cleaned_len >= MAXPATHLEN || zip_stat_index(za, idx, 0, &sb) != 0) {
+ CWD_STATE_FREE(new_state.cwd);
+ return 0;
+ }
+@@ -229,7 +235,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ return 0;
+ }
+
+- zf = zip_fopen(za, file, 0);
++ zf = zip_fopen_index(za, idx, 0);
+ if (zf == NULL) {
+ n = -1;
+ goto done;
+@@ -2815,7 +2821,7 @@ PHP_METHOD(ZipArchive, extractTo)
+ uint32_t nelems, i;
+
+ if (files_str) {
+- if (!php_zip_extract_file(intern, pathto, ZSTR_VAL(files_str), ZSTR_LEN(files_str))) {
++ if (!php_zip_extract_file(intern, pathto, ZSTR_VAL(files_str), ZSTR_LEN(files_str), -1)) {
+ RETURN_FALSE;
+ }
+ } else if (files_ht) {
+@@ -2830,7 +2836,7 @@ PHP_METHOD(ZipArchive, extractTo)
+ case IS_LONG:
+ break;
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -2847,8 +2853,8 @@ PHP_METHOD(ZipArchive, extractTo)
+ }
+
+ for (i = 0; i < filecount; i++) {
+- char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED);
+- if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file))) {
++ const char *file = zip_get_name(intern, i, ZIP_FL_UNCHANGED);
++ if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file), i)) {
+ RETURN_FALSE;
+ }
+ }
+diff --git a/php81/php_zip.c b/php81/php_zip.c
+index 35c3dee..ee92d34 100644
+--- a/php81/php_zip.c
++++ b/php81/php_zip.c
+@@ -126,7 +126,7 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */
+ # define CWD_STATE_FREE(s) efree(s)
+
+ /* {{{ php_zip_extract_file */
+-static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t file_len)
++static int php_zip_extract_file(struct zip * za, char *dest, const char *file, size_t file_len, zip_int64_t idx)
+ {
+ php_stream_statbuf ssb;
+ struct zip_file *zf;
+@@ -144,6 +144,12 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ cwd_state new_state;
+ zend_string *file_basename;
+
++ if (idx <0) {
++ idx = zip_name_locate(za, file, 0);
++ if (idx < 0) {
++ return 0;
++ }
++ }
+ new_state.cwd = CWD_STATE_ALLOC(1);
+ new_state.cwd[0] = '\0';
+ new_state.cwd_length = 0;
+@@ -159,7 +165,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ }
+ path_cleaned_len = strlen(path_cleaned);
+
+- if (path_cleaned_len >= MAXPATHLEN || zip_stat(za, file, 0, &sb) != 0) {
++ if (path_cleaned_len >= MAXPATHLEN || zip_stat_index(za, idx, 0, &sb) != 0) {
+ CWD_STATE_FREE(new_state.cwd);
+ return 0;
+ }
+@@ -234,7 +240,7 @@ static int php_zip_extract_file(struct zip * za, char *dest, char *file, size_t
+ return 0;
+ }
+
+- zf = zip_fopen(za, file, 0);
++ zf = zip_fopen_index(za, idx, 0);
+ if (zf == NULL) {
+ n = -1;
+ goto done;
+@@ -2830,7 +2836,7 @@ PHP_METHOD(ZipArchive, extractTo)
+ uint32_t nelems, i;
+
+ if (files_str) {
+- if (!php_zip_extract_file(intern, pathto, ZSTR_VAL(files_str), ZSTR_LEN(files_str))) {
++ if (!php_zip_extract_file(intern, pathto, ZSTR_VAL(files_str), ZSTR_LEN(files_str), -1)) {
+ RETURN_FALSE;
+ }
+ } else if (files_ht) {
+@@ -2845,7 +2851,7 @@ PHP_METHOD(ZipArchive, extractTo)
+ case IS_LONG:
+ break;
+ case IS_STRING:
+- if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file))) {
++ if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), -1)) {
+ RETURN_FALSE;
+ }
+ break;
+@@ -2862,8 +2868,8 @@ PHP_METHOD(ZipArchive, extractTo)
+ }
+
+ for (i = 0; i < filecount; i++) {
+- char *file = (char*)zip_get_name(intern, i, ZIP_FL_UNCHANGED);
+- if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file))) {
++ const char *file = zip_get_name(intern, i, ZIP_FL_UNCHANGED);
++ if (!file || !php_zip_extract_file(intern, pathto, file, strlen(file), i)) {
+ RETURN_FALSE;
+ }
+ }