php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch ziparchive-remove-path-length-option.patch for zip Bug #72374

Patch version 2016-06-10 07:57 UTC

Return to Bug #72374 | Download this patch
Patch Revisions:

Developer: namatyage@gmail.com

diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 88bb518..9080382 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1652,6 +1652,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
 		size_t real_len = strlen(remove_path);
 		if ((real_len > 1) && ((remove_path[real_len - 1] == '/') || (remove_path[real_len - 1] == '\\'))) {
 			remove_path[real_len - 1] = '\0';
+			remove_path_len -= 1;
 		}
 	}
 
@@ -1677,8 +1678,8 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
 					file_stripped = ZSTR_VAL(basename);
 					file_stripped_len = ZSTR_LEN(basename);
 				} else if (remove_path && strstr(Z_STRVAL_P(zval_file), remove_path) != NULL) {
-					file_stripped = Z_STRVAL_P(zval_file) + remove_path_len + 1;
-					file_stripped_len = Z_STRLEN_P(zval_file) - remove_path_len - 1;
+					file_stripped = Z_STRVAL_P(zval_file) + remove_path_len;
+					file_stripped_len = Z_STRLEN_P(zval_file) - remove_path_len;
 				} else {
 					file_stripped = Z_STRVAL_P(zval_file);
 					file_stripped_len = Z_STRLEN_P(zval_file);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC