summaryrefslogtreecommitdiff
path: root/ext/zip
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-09-14 15:03:52 +0200
committerAnatol Belski <ab@php.net>2014-09-14 15:03:52 +0200
commit454548e44032d40ba49e2041c552bedbff49a468 (patch)
tree15f791761d19ce5566c96b694033cc478044bbac /ext/zip
parent6a92d321050eebbbd959f5b98cf9eff122faf91e (diff)
downloadphp-git-454548e44032d40ba49e2041c552bedbff49a468.tar.gz
make it safer for an array underrun
Diffstat (limited to 'ext/zip')
-rw-r--r--ext/zip/php_zip.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index 0f6a6bfe88..4cac8b32bc 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1610,9 +1610,9 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /*
}
if (remove_path && remove_path_len > 1) {
- int tmp_idx = (int)strlen(remove_path) - 1;
- if (remove_path[tmp_idx] == '/' || remove_path[tmp_idx] == '\\') {
- remove_path[tmp_idx] = '\0';
+ 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';
}
}