diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index fc461e4644e..9f798d8afaa 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -90,8 +90,8 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */ return NULL; } - if (IS_SLASH(path[0])) { - return path + 1; + if (IS_ABSOLUTE_PATH(path, path_len)) { + return path + COPY_WHEN_ABSOLUTE(path) + 1; } i = path_len; diff --git a/ext/zip/tests/bug81420.phpt b/ext/zip/tests/bug81420.phpt new file mode 100644 index 00000000000..9eec0ee7e99 --- /dev/null +++ b/ext/zip/tests/bug81420.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #81420 (ZipArchive::extractTo extracts outside of destination) +--SKIPIF-- + +--FILE-- +open(__DIR__ . "/bug81420.zip"); +$destination = __DIR__ . "/bug81420"; +mkdir($destination); +$zip->extractTo($destination); +var_dump(file_exists("$destination/nt1/zzr_noharm.php")); +?> +--CLEAN-- + +--EXPECT-- +bool(true) diff --git a/ext/zip/tests/bug81420.zip b/ext/zip/tests/bug81420.zip new file mode 100644 index 00000000000..2e9686cb98a Binary files /dev/null and b/ext/zip/tests/bug81420.zip differ