diff options
author | Anatol Belski <ab@php.net> | 2014-09-14 15:03:52 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-09-14 15:03:52 +0200 |
commit | 454548e44032d40ba49e2041c552bedbff49a468 (patch) | |
tree | 15f791761d19ce5566c96b694033cc478044bbac /ext/zip | |
parent | 6a92d321050eebbbd959f5b98cf9eff122faf91e (diff) | |
download | php-git-454548e44032d40ba49e2041c552bedbff49a468.tar.gz |
make it safer for an array underrun
Diffstat (limited to 'ext/zip')
-rw-r--r-- | ext/zip/php_zip.c | 6 |
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'; } } |