]> granicus.if.org Git - php/commit
Fix #53467: Phar cannot compress large archives
authorChristoph M. Becker <cmbecker69@gmx.de>
Tue, 26 Jan 2021 16:46:32 +0000 (17:46 +0100)
committerChristoph M. Becker <cmbecker69@gmx.de>
Wed, 3 Feb 2021 10:22:37 +0000 (11:22 +0100)
commit1bb2a4f91cfde36ba343184f3d88189e646cc363
treed234e4ac8965445653a6c29ea2615f92dbeada8d
parent3d09626f0d3f43494352f9c5d9a6b6a0a91515ef
Fix #53467: Phar cannot compress large archives

When Phars are flushed, a new temporary file is created for each entry
which should be compressed, and the `compressed_filesize` is retrieved.
Afterwards, the Phar manifest is written, and only after that the files
are copied to the actual Phar.  So for each such entry there is an open
temp file, what easily exceeds the limit.

Therefore, we use a single temporary file for all entries, and store
the start offset in the otherwise unused `header_offset` member.  We
ensure that the `cfp` members are properly set to NULL even if flushing
fails, to avoid use after free scenarios.

This solution is based on a suggestion by @lserni[1].

Closes GH-6643.

[1] <https://github.com/box-project/box2/issues/80#issuecomment-77147371>
NEWS
ext/phar/phar.c