Gzip
Gzip is a lossless compressed-file format whose file consists of a sequence of members, each carrying a compressed data stream and a trailer with CRC32 and uncompressed size modulo 2^32.
A member is a compression unit, not a TAR entry or full recovery object. Removing one can leave valid but incomplete input. Python gzip handles concatenation; zlib inflate stops at a member boundary and leaves continuation to its caller. Method 8 is DEFLATE, not a zlib wrapper. [1] [2] [5] [10]
CPython 3.12.3/zlib 1.3 controls returned expected bytes before EOF exposed a bad trailer; close did not finish validation. decompressobj plus flush returned bytes with eof false. unused_data marks post-stream input, not validation success. [3] [6]
Data CRC32 excludes headers. Optional FHCRC is the low 16 header-CRC bits; RFC 1952 permits skipping it but requires rejection of reserved flag bits. Tested Python accepted stale FHCRC and reserved flags rejected by zlib 1.3 and GNU gzip 1.12. Resealing a name change restored acceptance, not identity. [1] [4] [8] [9]
Native gzread accepts plain input and ignores trailing non-gzip material. Read failure can precede successful close; zero read can accompany truncation reported by gzerror and close. Preserve read and terminal errors. [5] [9]
Tested GNU 1.14 lists aggregate decoded size but the last member's CRC; 1.12 lists last-member size. GNU 1.11 can report unknown sizes on a pipe despite exit zero. Modern listing performs decompression; it is not a free output-budget check. Full intended length and identity need separate expectations. [11] [12]
Matching version labels do not identify interpreter or library binaries. Replay separates changed outcomes from changed environment metadata; agreement on tested inputs is not independent replication. [13]
Relations
- related
- Archive member, Backup manifest, Checksum, Zstandard, Restore test, Blocked GNU Zip Format (BGZF), DEFLATE
Limitations
- Complete gzip validation does not establish coverage of the decoded container. Concatenated gzip members can decode to separately terminated TARs, whose default reader stops after the first. [7]
Citations
- RFC 1952: GZIP file format specification 4.3, sections 2.2, 2.3.1 and 2.3.1.2
- Python 3.12 gzip documentation: multi-member decompression and errors
- Python 3.12 zlib documentation: eof, unused_data and unconsumed_tail
- CPython v3.12.3 gzip.py: GzipFile.close and _GzipReader._read_eof
- zlib v1.3 public interface: inflate stops at a gzip member boundary
- Hesela: 42 gzip API operations distinguish trailer checks, member completion and expected content
- Hesela: TAR boundaries after complete gzip validation, 48 reader observations
- zlib v1.3 inflate.c: FLAGS and HCRC checks
- Hesela: gzip header checks and native reader status, 238 designed observations
- RFC 1951: DEFLATE format, sections 2 and 3.2-3.3 (Informational, May 1996)
- GNU gzip 1.14 release: multi-member listing fix (9 April 2025)
- Hesela: gzip listing size and CRC scope, 99 version/input observations
- Hesela: gzip replay separates experimental outcomes from environment identity
Sources & caveats
- Primary-source synthesis plus seven synthetic fixtures, not field reliability evidence. No third-party payload or source code redistributed.
- Reproduction: https://hesela.dev/research/gzip-read-coverage.py ; observations: https://hesela.dev/research/gzip-read-coverage.json . Python standard library only; caller-returned bytes, not physical I/O.
- Header/flag experiment: https://hesela.dev/research/gzip-header-contract.zip . Original 2026-10-22 captures retained; 2026-11-09 same-host replay matches fixtures and outcomes with kernel/libz-binary drift recorded separately. No independent review or field-rate claim.
- GNU listing controls: https://hesela.dev/research/gzip-list-evidence/reproduction.zip . Three versions, eleven synthetic fixtures, three input modes; same-host replay, not independent peer replication.