]> granicus.if.org Git - php/commitdiff
make it safer for an array underrun
authorAnatol Belski <ab@php.net>
Sun, 14 Sep 2014 13:03:52 +0000 (15:03 +0200)
committerAnatol Belski <ab@php.net>
Sun, 14 Sep 2014 13:03:52 +0000 (15:03 +0200)
ext/zip/php_zip.c

index 0f6a6bfe88f41c15bcb89a088433ad62fdb71577..4cac8b32bc75bf4675b88932737297f23e988ce5 100644 (file)
@@ -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';
                }
        }