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:Libdeflate

From ReverseEngineering.wiki
Library
Developer Eric Biggers
Versions 1.26 in the current repository (LIBDEFLATE_VERSION_STRING)
License MIT
Website https://github.com/ebiggers/libdeflate
On this wiki Facts · Code · Notes · Topics

Eric Biggers' fast whole-buffer DEFLATE, zlib and gzip compressor and decompressor (C, MIT): no streaming API, libdeflate_* function names, no copyright banner or version string in the library code, and its own table-driven decoder (precode/litlen/offset decode_results) instead of zlib's inftrees tables.

Overview

libdeflate compresses and decompresses whole buffers (libdeflate_deflate_compress, libdeflate_zlib_compress, libdeflate_gzip_compress and the matching *_decompress, *_decompress_ex, libdeflate_adler32, libdeflate_crc32) with compression levels 0-12. It is also wrapped by bindings for other languages. Output is standard DEFLATE (Format:DEFLATE), readable by Library:Zlib and everything else.

Identification

  • Names: exported or debug-visible functions libdeflate_alloc_compressor, libdeflate_alloc_decompressor, libdeflate_free_compressor, libdeflate_free_decompressor, libdeflate_set_memory_allocator (libdeflate.h). The headers define LIBDEFLATE_VERSION_STRING ("1.26" at the pinned commit), but the library code never returns it at run time; only the command-line programs print it, so a stripped library has no version string.
  • Compressor tables (lib/deflate_compress.c lines 237-268): deflate_length_slot_base[] (3,4,5,...,258 as 32-bit), deflate_extra_length_bits[] (28 bytes, ending 5,5,5,5,0), deflate_offset_slot_base[] (1,...,24577) and deflate_extra_offset_bits[] (0,0,0,0,1,1,...,13,13; 30 entries): no padding entries like zlib's 31/32-entry tables, which separates it from zlib, miniz and zlib-ng.
  • Decompressor tables: three u32 arrays precode_decode_results, litlen_decode_results (the 256 literal entries first, each HUFFDEC_LITERAL | literal << 16) and offset_decode_results in lib/deflate_decompress.c (lines 407, 504, 617). deflate_precode_lens_permutation is the standard 16,17,18,0,8,7,9,...; bitreverse_tab[256] appears in the compressor.
  • CRC-32: crc32_slice1_table (starts 0x00000000 0x77073096 0xEE0E612C 0x990951BA, the zlib table) and a larger crc32_slice8_table (lib/crc32_tables.h); on x86 and ARM, carry-less multiply constants in crc32_multipliers.h replace them. Adler-32 is the usual 65521 modulus.
  • Behaviour: decompress calls return enum libdeflate_result (0 success, 1 bad data, 2 short output, 3 insufficient space); there is no inflate() state machine, so there is no z_stream.

Code & repositories

  • https://github.com/ebiggers/libdeflate @ 92e6a0db9fa848d742f9eb286c92afc60f2c3dda · license: MIT
    libdeflate source: lib/ has the DEFLATE compressor and decompressor, zlib and gzip wrappers, CRC-32 and Adler-32; NEWS.md lists the versions.
    Tested on: source read, not run: source read at the pinned commit; nothing built or run · checked 2026-10-18; last activity 2026-08-22; Note: the latest release ships binaries; the wiki links only the source, never the binaries

Pitfalls

  • A stripped statically linked libdeflate is told from zlib by the missing lext pattern and the unpadded compressor tables. Source check at commit 92e6a0db9fa848d742f9eb286c92afc60f2c3dda: neither lib/deflate_decompress.c nor lib/deflate_compress.c contains any lext, lbase or dext array (a text search finds none), while zlib and zlib-ng keep them in inftrees.c (Library:Zlib-ng#Identification). This is a statement about the source; no compiled binary was inspected.

Evidence & references

  • ebiggers/libdeflate commit 92e6a0db9fa848d742f9eb286c92afc60f2c3dda: libdeflate.h, lib/deflate_compress.c, lib/deflate_decompress.c, lib/crc32_tables.h. Read only.