PSAR: Accept zlib 1.4's error for streams without a checksum

zlib 1.4's uncompress2 returns Z_DATA_ERROR, not Z_BUF_ERROR, when the input
runs out with the output full, so every file in the pre-decrypted 3.60 archive
failed to inflate after the zlib update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-11-06 14:08:57 +01:00
1 parent a0af2bc403
commit 004dcdfe93
1 file changed
+3 -2
+3 -2
View File
@@ -739,8 +739,9 @@ void PSARReader::EnsureContents() {
uLongf destLen = contentExpandedSize_;
uLong sourceLen = decoded;
int zResult = uncompress2(entryData_.data(), &destLen, block2_.data(), &sourceLen);
// Handle zip streams missing their Adler-32 checksum.
if (zResult == Z_BUF_ERROR && sourceLen == (uLong)decoded && destLen == contentExpandedSize_ && decrypted_) {
// Handle zip streams missing their Adler-32 checksum (the pre-decrypted 3.60 archive's). The
// input runs out with the output full, which zlib 1.4 reports as Z_DATA_ERROR, 1.3 as Z_BUF_ERROR.
if ((zResult == Z_BUF_ERROR || zResult == Z_DATA_ERROR) && sourceLen == (uLong)decoded && destLen == contentExpandedSize_ && decrypted_) {
zResult = Z_OK;
}
if (zResult != Z_OK || destLen != contentExpandedSize_) {