Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Library:LZO

From ReverseEngineering.wiki
Library
Developer Markus F.X.J. Oberhumer
Platforms any (portable ANSI C)
Versions 2.10 (1 Mar 2017) is the latest release in the mirror used
License GPL-2.0-or-later (commercial license available)
Website http://www.oberhumer.com/opensource/lzo/
On this wiki Facts · Code · Notes · Topics

Markus Oberhumer's LZO real-time compression library (C, GPL-2.0-or-later or commercial) and its miniLZO subset: raw LZO1X blocks have no magic; the lzop file wrapper starts with 89 4C 5A 4F 00 0D 0A 1A 0A; the library stores a version string and date.

Overview

LZO is a family of very fast LZ77 compressors (LZO1, LZO1A, LZO1B, LZO1C, LZO1F, LZO1X, LZO1Y, LZO1Z, LZO2A). LZO1X-1 is the common one: in the Linux kernel (zram, squashfs, UBIFS, btrfs), game save files, UPX-like packers, and many embedded firmwares. miniLZO is a small LZO1X-only subset in the files minilzo.c/minilzo.h that programs copy into their source tree.

Identification

  • Header lzoconf.h defines LZO_VERSION 0x20a0, LZO_VERSION_STRING "2.10" and LZO_VERSION_DATE "Mar 01 2017". lzo_version(), lzo_version_string() and lzo_version_date() return them, and the string is kept in the library binary, so a search for 2.10 next to Mar 01 2017 dates a linked copy. miniLZO has its own MINILZO_VERSION (0x20a0 for 2.10).
  • Exported/linked names: lzo_init (checked via the macro __lzo_init_v2 with struct sizes), lzo1x_1_compress, lzo1x_decompress, lzo1x_decompress_safe, lzo1x_999_compress, lzo1x_optimize.
  • A raw LZO1X block has no magic and no length header. Its end is marked by the bytes 11 00 00 (a match with distance 16384 and length 0: instruction 17 followed by two zero bytes). The first byte of an LZO1X block is a literal run or a value above 17, which is how a decoder starts.
  • Decompression code shape (used by the capa rule 'decompress data using LZO'): immediates 0xFF (length run 255), 0x1F (mask), 0x4000 subtraction (m_pos -= 0x4000), shifts by 2, and the 3-byte constant 0xFFFFFFFC masking.
  • lzop file wrapper (the lzop tool, .lzo files): magic 89 4C 5A 4F 00 0D 0A 1A 0A (0x89 'LZO' NUL CR LF Ctrl-Z LF), then version fields, method, level, flags, mode, mtime, name, header checksum (Adler-32 or CRC-32), followed by blocks with big-endian uncompressed/compressed sizes and per-block checksums. The lzop magic is confirmed in the lzop program source (lzop-1.04.tar.gz from lzop.org, src/lzop.c line 627): static const unsigned char lzop_magic[9] = { 0x89, 0x4c, 0x5a, 0x4f, 0x00, 0x0d, 0x0a, 0x1a, 0x0a }. The lzo repository itself does not contain lzop.

Pitfalls

  • LZO is GPL: closed-source programs that include it have usually bought a commercial license, or use a re-implementation (e.g. QuickLZ, LZ4, or the clean-room decoders in the Linux kernel and in lzo-rs). Re-implementations lack the version string.
  • UCL, NRV and aPLib come from the same family of authors/ideas but have different formats; the capa rules separate 'decompress data using UCL' and 'aplib'.

Code & repositories

See the linked repository (a GitHub mirror of the 2.10 release).

  • https://github.com/nemequ/lzo @ 0083878c235a89ef96a009d1ff0b500f3a364e4b · license: GPL-2.0
    GitHub mirror of LZO 2.10 (lzoconf.h, minilzo)
    Tested on: source read, not run: source only · checked 2026-10-18; last activity 2022-04-19

Open questions

  • What does lzop write in its header for each lzop version (0x1030 etc.)? Not checked.