Format:Lzip
| Developer | Antonio Diaz Diaz (lzip, 2008) |
|---|---|
| Uses | Library:Liblzma (decoder only) |
| Magic | 4C 5A 49 50 ("LZIP") at 0, then version 01 |
| Extensions | .lz, .tlz (tar.lz) |
| Endianness | little |
| On this wiki | Facts · Code · Notes · Topics |
Antonio Diaz Diaz's compressed file format (.lz; lzip, plzip, lziprecover; also decoded by liblzma 5.4.0 and later): one or more members, each a 6-byte header ("LZIP", version, coded dictionary size), an LZMA stream with fixed lc=3 lp=0 pb=2 that ends with an end marker, and a 20-byte trailer (CRC32, data size, member size).
Layout
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | LZIP (4C 5A 49 50)
|
| 4 | 1 | version: 1 (0 in very old files) |
| 5 | 1 | coded dictionary size (below) |
| 6 | n | Format:LZMA stream, lc=3 lp=0 pb=2, with end-of-payload marker; first byte 00 |
| end-20 | 4 | CRC32 (zlib polynomial) of the uncompressed data, LE |
| end-16 | 8 | uncompressed size, u64 LE |
| end-8 | 8 | member size including header and trailer, u64 LE (version 1 only; the version 0 trailer is 12 bytes) |
Members can be concatenated, and the format allows arbitrary non-lzip data after the last member (liblzma stops there and returns LZMA_STREAM_END without consuming it).
Dictionary size byte
Bits 0-4 are log2 of a base size, bits 5-7 a numerator: size = 2^b - (n * 2^b) / 16. Valid sizes are 4 KiB to 512 MiB (b 12-29, and n must be 0 when b is 12). Examples: 0x0C = 4 KiB, 0x10 = 64 KiB, 0x17 = 8 MiB, 0xB5 = 2 MiB - 5/16 = 1408 KiB, 0x1D = 512 MiB.
Identification
LZIP + 01 at the start of a file or stream; the last 8 bytes of a single-member file equal its length. Inside programs, liblzma's lzip decoder compares the four ID bytes one at a time, but GCC keeps them as the immediate 0x50495A4C (seen in liblzma 5.6.3 for Windows: C7 84 24 .. .. .. .. 4C 5A 49 50).
Code & repositories
- https://github.com/tukaani-project/xz @
299eb5c3f597f107fd6019bf156885ac8bfaa5ea· license: 0BSD AND LGPL-2.1-or-later AND GPL-2.0-or-later (declared by the contributor; GitHub's detector did not recognize COPYING)
Official XZ Utils repository: liblzma (src/liblzma, 0BSD), the xz tools, the .xz and .lzma format specifications (doc/xz-file-format.txt, doc/lzma-file-format.txt, public domain) and the test files in tests/files. Release tags v5.0.0 onwards let you diff the tables of any version found in a binary. Per COPYING: liblzma and the tools are 0BSD, the getopt fallback LGPL-2.1+, the xzgrep/xzdiff scripts GPL-2.0+.
Tested on: Read at this commit and at tags v5.0.0, v5.2.5, v5.4.0, v5.6.0 (filter_common.c, price_table.c, fastpos_table.c, crc64_table_*.h, lzma2_decoder.c, lzip_decoder.c, liblzma_linux.map); behaviour checked with Python 3.11 lzma and ctypes calls into a MinGW-w64 liblzma-5.dll 5.6.3; not built. · checked 2026-10-17; last activity 2026-10-16; Note: the latest release ships binaries; the wiki links only the source, never the binaries
Pitfalls
- liblzma's
lzma_lzip_decoder()andlzma_auto_decoder()(5.4.0+) read versions 0 and 1 only and reject newer versions with LZMA_OPTIONS_ERROR; they cannot write .lz. - The LZMA parameters are not stored: a decoder that takes them from a header byte (as for .lzma) will mis-decode.
Evidence & references
- src/liblzma/common/lzip_decoder.c (lines 19-26, 100-215, 270-330) in https://github.com/tukaani-project/xz at commit 299eb5c3f597f107fd6019bf156885ac8bfaa5ea.
- Test: a version 1 member built by hand (header
4C 5A 49 50 01 10, Pythonlzmaraw LZMA1 with end marker, trailer) was decoded by liblzma 5.6.3'slzma_lzip_decoderandlzma_auto_decoder(ctypes) to the original 550 bytes; flipping one CRC bit gave LZMA_DATA_ERROR (9). Not tested against files written by lzip itself.