diff options
author | Remi Collet <remi@php.net> | 2020-02-28 10:29:30 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2020-02-28 10:29:30 +0100 |
commit | 165d38a38d99817598dd920b4c64a0fdc12808da (patch) | |
tree | 9025fcd07255bda9722ae6f6d1691506915819db /ext/zip | |
parent | c5e8c25dda0c98ec16b6386a23ed6d2a9e5df0b0 (diff) | |
parent | 3725faa3dbb598e2fe7d522c69354f735ef99d9f (diff) | |
download | php-git-165d38a38d99817598dd920b4c64a0fdc12808da.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
NEWS
Fix #79315 ZipArchive::addFile doesn't honor start/length parameters
Diffstat (limited to 'ext/zip')
-rw-r--r-- | ext/zip/php_zip.c | 3 | ||||
-rw-r--r-- | ext/zip/tests/oo_addfile.phpt | 13 |
2 files changed, 14 insertions, 2 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index eadbd0e76e..e2be7fc668 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1747,7 +1747,8 @@ static ZIPARCHIVE_METHOD(addFile) entry_name_len = ZSTR_LEN(filename); } - if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), entry_name, entry_name_len, 0, 0) < 0) { + if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), + entry_name, entry_name_len, offset_start, offset_len) < 0) { RETURN_FALSE; } else { RETURN_TRUE; diff --git a/ext/zip/tests/oo_addfile.phpt b/ext/zip/tests/oo_addfile.phpt index 5dd99faa0b..e7777a697d 100644 --- a/ext/zip/tests/oo_addfile.phpt +++ b/ext/zip/tests/oo_addfile.phpt @@ -20,13 +20,17 @@ if (!$zip->open($file)) { if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) { echo "failed\n"; } +if (!$zip->addFile($dirname . 'utils.inc', 'mini.txt', 12, 34)) { + echo "failed\n"; +} if ($zip->status == ZIPARCHIVE::ER_OK) { if (!verify_entries($zip, [ "bar", "foobar/", "foobar/baz", "entry1.txt", - "test.php" + "test.php", + "mini.txt" ])) { echo "failed\n"; } else { @@ -36,7 +40,14 @@ if ($zip->status == ZIPARCHIVE::ER_OK) { } else { echo "failed\n"; } +if (!$zip->open($file)) { + exit('failed'); +} +var_dump(strlen($zip->getFromName('test.php')) == filesize($dirname . 'utils.inc')); +var_dump(strlen($zip->getFromName('mini.txt')) == 34); @unlink($file); ?> --EXPECT-- OK +bool(true) +bool(true) |