[GZip] Adjust detection of truncated inputs

This commit is contained in:
Timofey Solomko
2022-05-17 13:33:04 +03:00
parent d63fb86f49
commit 74ae7c2edc
+3 -2
View File
@@ -77,8 +77,9 @@ public class GzipArchive: Archive {
}
private static func processMember(_ bitReader: LsbBitReader) throws -> Member {
// Valid GZip archive must contain at least 18 bytes of data (10 for header and 8 for checksums).
guard bitReader.bitsLeft >= 18 * 8
// Valid GZip archive must contain at least 20 bytes of data (10 for the header, 2 for an empty Deflate block,
// and 8 for checksums).
guard bitReader.bitsLeft >= 20 * 8
else { throw GzipError.wrongMagic }
let header = try GzipHeader(bitReader)