Fix GH-22885: SEGV when setting the comment of a modified zip entry - #22892
Fix GH-22885: SEGV when setting the comment of a modified zip entry#22892khaledalam wants to merge 1 commit into
Conversation
|
Quite a radical fix I think at the first glance. However I do know why your fix is way more bigger than I expected since you've chosen a robuster way I haven't thought of. I will take a look ASAP. |
9899601 to
c8b9e32
Compare
|
Can the following test be added ? |
c8b9e32 to
9466868
Compare
LamentXU123
left a comment
There was a problem hiding this comment.
Could you please add these cases in tests? I doubt these are bugs:
<?php
$file = __DIR__ . "/poc_encryption_failed.zip";
@unlink($file);
$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE);
$zip->addFromString("a.txt", "data");
$zip->setCommentName("a.txt", "old comment");
$zip->close();
$zip->open($file);
var_dump($zip->setEncryptionName("a.txt", 9999, "pw"));
var_dump($zip->setCommentName("a.txt", "new comment"));
$zip->close();
<?php
$file = __DIR__ . "/poc_false_positive.zip";
@unlink($file);
$zip = new ZipArchive();
$zip->open($file, ZipArchive::CREATE);
$zip->addFromString("a.txt", "data");
$zip->setCommentName("a.txt", "old comment");
$zip->close();
$zip->open($file);
var_dump($zip->setCommentName("a.txt", "first new comment"));
var_dump($zip->setMtimeName("a.txt", 1000000));
var_dump($zip->setCommentName("a.txt", "second new comment"));
$zip->close();
|
Did we not fix this already in a previous PR? that one #22652 I cannot reproduce using master. Not sure if that merge was back-ported to previous stable branches. |
|
#22652 fixes the identical-comment reset case. this PR handles the remaining modified-entry or different-comment cases. So they are different bugs |
|
And the fix only affect low libzip versions as a workaround. So most people with a not ancient libzip isn't affected. |
Fixes GH-22885.