summaryrefslogtreecommitdiff
path: root/ext/zip/php_zip.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2019-10-08 09:49:24 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2019-10-08 09:49:46 +0200
commit88e0d888976602c947e9bd50eae6c4e99dcdc2aa (patch)
tree6eb2961a5d6c4e8adf424c8640bb9671db5954c0 /ext/zip/php_zip.c
parent5eebd5539183a46929570e00e967cf16ebca97ce (diff)
parent11654fdfa6b2519d7c727fa76829687e282b2539 (diff)
downloadphp-git-88e0d888976602c947e9bd50eae6c4e99dcdc2aa.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78641: addGlob can modify given remove_path value
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r--ext/zip/php_zip.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 8b25d7dcbd..966efb58e6 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1645,7 +1645,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
struct zip *intern;
zval *self = ZEND_THIS;
char *path = ".";
- char *remove_path = NULL;
+ char *remove_path = NULL, *save_remove_path;
char *add_path = NULL;
size_t add_path_len, remove_path_len = 0, path_len = 1;
zend_long remove_all_path = 0;
@@ -1677,10 +1677,11 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
RETURN_FALSE;
}
+ save_remove_path = remove_path;
if (remove_path && remove_path_len > 1) {
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 = estrndup(remove_path, real_len - 1);
}
}
@@ -1740,6 +1741,9 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
}
}
}
+ if (remove_path != save_remove_path) {
+ efree(remove_path);
+ }
}
/* }}} */