diff options
author | Remi Collet <remi@php.net> | 2020-02-28 10:35:39 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2020-02-28 10:35:39 +0100 |
commit | 7f0d3f1eab7230031b92fe582fc1f33fd5732576 (patch) | |
tree | 9c53208ce5fd3abbedc9b3829ed66ffb829bd780 /ext/zip | |
parent | 6d19acf54b1553f1f1e9156b85c22a53b10a9c8e (diff) | |
parent | d31fc591e0a852c69b81b3311b3609221f66c445 (diff) | |
download | php-git-7f0d3f1eab7230031b92fe582fc1f33fd5732576.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
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 22f9895ad8..9d704b0cbf 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1791,7 +1791,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 254f2b7620..84dea86614 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) |