Skip to content

Commit 7f0d3f1

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79315 ZipArchive::addFile doesn't honor start/length parameters
2 parents 6d19acf + d31fc59 commit 7f0d3f1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

ext/zip/php_zip.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1791,7 +1791,8 @@ static ZIPARCHIVE_METHOD(addFile)
17911791
entry_name_len = ZSTR_LEN(filename);
17921792
}
17931793

1794-
if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), entry_name, entry_name_len, 0, 0) < 0) {
1794+
if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename),
1795+
entry_name, entry_name_len, offset_start, offset_len) < 0) {
17951796
RETURN_FALSE;
17961797
} else {
17971798
RETURN_TRUE;

ext/zip/tests/oo_addfile.phpt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ if (!$zip->open($file)) {
2020
if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) {
2121
echo "failed\n";
2222
}
23+
if (!$zip->addFile($dirname . 'utils.inc', 'mini.txt', 12, 34)) {
24+
echo "failed\n";
25+
}
2326
if ($zip->status == ZIPARCHIVE::ER_OK) {
2427
if (!verify_entries($zip, [
2528
"bar",
2629
"foobar/",
2730
"foobar/baz",
2831
"entry1.txt",
29-
"test.php"
32+
"test.php",
33+
"mini.txt"
3034
])) {
3135
echo "failed\n";
3236
} else {
@@ -36,7 +40,14 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
3640
} else {
3741
echo "failed\n";
3842
}
43+
if (!$zip->open($file)) {
44+
exit('failed');
45+
}
46+
var_dump(strlen($zip->getFromName('test.php')) == filesize($dirname . 'utils.inc'));
47+
var_dump(strlen($zip->getFromName('mini.txt')) == 34);
3948
@unlink($file);
4049
?>
4150
--EXPECT--
4251
OK
52+
bool(true)
53+
bool(true)

0 commit comments

Comments
 (0)