Skip to content

Commit 165d38a

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: NEWS Fix #79315 ZipArchive::addFile doesn't honor start/length parameters
2 parents c5e8c25 + 3725faa commit 165d38a

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
@@ -1747,7 +1747,8 @@ static ZIPARCHIVE_METHOD(addFile)
17471747
entry_name_len = ZSTR_LEN(filename);
17481748
}
17491749

1750-
if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename), entry_name, entry_name_len, 0, 0) < 0) {
1750+
if (php_zip_add_file(intern, ZSTR_VAL(filename), ZSTR_LEN(filename),
1751+
entry_name, entry_name_len, offset_start, offset_len) < 0) {
17511752
RETURN_FALSE;
17521753
} else {
17531754
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)