Repository navigation
Fix GH-21705: ZipArchive::getFromIndex() ignores ZipArchive::FL_UNCHANGED for deleted entries - #21706
Conversation
|
One pre-existing concern worth flagging while we're touching this line: the I ran this on master + this patch: $zip->getFromName('bar.txt', 0, -1); // receives 0xFFFFFFFF (all libzip flags set)
$zip->getFromName('foo.txt', 0, PHP_INT_MAX); // receives lower 32 bits silently
$zip->getFromName('bar.txt', 0, 0x100000000); // truncates to 0, FL_UNCHANGED intent lost silentlyThe third case is the worst: the caller's flag intent lives in the upper 32 bits, truncates to zero on the way into libzip, and they get The same pattern shows up on all 15 |
|
@iliaal Could you please take a fast check on this PR? I want to get this fixed in 8.6. Thank you! |
|
LGTM, just needs a NEWS entry |
|
Thank you! |
…#21706) ZipArchive::getFromIndex() already passed flags to zip_fopen_index(), but it used an unflagged stat call to determine the entry size. Use the same flags for the stat lookup so deleted entries can still be read with ZipArchive::FL_UNCHANGED, matching ZipArchive::getFromName(). Closes php#21706
* PHP-8.4: Fix phpGH-21705: ZipArchive::getFromIndex() ignores FL_UNCHANGED (php#21706)
fixes #21705 by passing the correct flag into
PHP_ZIP_STAT_INDEXThe code is as follows:
when mode == 1 its for getFromName, where it calls
PHP_ZIP_STAT_PATHwith the correct argumentsflagswhen mode == 0 its for getFromIndex, where it calls
PHP_ZIP_STAT_INDEXwith flag be forced to 0It's quite bizarre.