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

From ReverseEngineering.wiki
Library
Developer Rich Geldreich (now maintained at richgel999/miniz)
Versions 2.x to 3.x; 11.3.2 in the current repository (MZ_VERSION)
License MIT
Website https://github.com/richgel999/miniz
On this wiki Facts · Code · Notes · Topics

Rich Geldreich's single-file zlib replacement (MIT; miniz.c with tinfl inflate and tdefl deflate, plus a ZIP reader/writer), compiled into many games, emulators and tools; its compat API uses zlib's names (mz_inflate, mz_uncompress) and its inflate tables differ from madler/zlib's, so zlib's signatures do not match it.

Overview

miniz is a zlib-compatible deflate/inflate library in one or two C files, with the low-level decompressor tinfl_decompress and compressor tdefl_compress, a zlib-style wrapper (mz_deflate, mz_inflate, mz_compress, mz_uncompress, mz_crc32, mz_adler32) and a ZIP archive reader and writer (mz_zip_*). It is widely copied into projects as a drop-in zlib replacement (unverified which products embed it; check the strings and tables below). It produces and reads the same formats as Library:Zlib (Format:DEFLATE, Format:Zlib stream) but is different code.

Identification

Differences from madler/zlib that can be searched for in a binary:

  1. Inflate tables (tinfl_decompress, src/miniz_tinfl.c lines 189-192) are stored as plain extra-bit counts: s_length_extra[31] = 0 x8, 1 x4, 2 x4, 3 x4, 4 x4, 5 x4, 0, 0, 0 and s_dist_extra[32] = 0,0,0,0,1,1,2,2,...,13,13 then 0,0 (bytes). zlib's lext[] has 16+n values and ends in a version-specific pair (Library:Zlib#Versions); a 0,0,0 tail means miniz. s_length_base[31] (3 .. 258, 0, 0) and s_dist_base[32] (1 .. 24577, 0, 0) are 16-bit and equal zlib's lbase/dbase.
  2. CRC-32: a default build compiles mz_crc32 with the full 256-entry table starting 00000000 77073096 EE0E612C 990951BA (miniz.c line 97), the same as zlib, so it does not identify miniz. The compact 16-entry nibble variant (0, 0x1DB71064, 0x3B6E20C8, 0x26D930AC, 0x76DC4190, 0x6B6B51F4, 0x4DB26158, 0x5005713C, 0xEDB88320, ..., lines 70-73) is inside a disabled #if 0 block at commit 2948eeb, so only code copied from it would contain it.
  3. Version string: mz_version() returns MZ_VERSION ("11.3.2" in the repository head, miniz.h line 286); release 2.x strings look like "10.2.0" (the numbering is miniz's own, not zlib's). In the zlib compat layer ZLIB_VERSION is defined as MZ_VERSION.
  4. Error strings mz_error(): "" , "stream end", "need dictionary", "file error", "stream error", "data error", "out of memory", "buf error", "version error", "parameter error" (miniz.c lines 599-607). zlib's own are "insufficient memory", "buffer error", "incompatible version" and it has no "parameter error".
  5. No copyright banners like zlib's " inflate 1.3.1 Copyright 1995-2024 Mark Adler "; tinfl code has a distinctive TINFL_FLAG_* state machine and the table s_tdefl_len_sym/s_tdefl_len_extra when deflate is present.

Code & repositories

  • https://github.com/richgel999/miniz @ 2948eebafc5b9f1c69bebed80333e403a09bd62d · license: MIT
    miniz source: miniz.c / miniz_tinfl.c / miniz_tdef.c (inflate and deflate), miniz_zip.c (ZIP); ChangeLog.md lists the version history.
    Tested on: source read, not run: source read at the pinned commit; nothing built or run · checked 2026-10-18; last activity 2026-10-04; Note: the latest release ships binaries; the wiki links only the source, never the binaries

Pitfalls

  • Many programs rename the functions (mz_ to a project prefix) or build with MINIZ_NO_ZLIB_COMPATIBLE_NAMES; the tables remain.
  • Because miniz can replace the CRC with a smaller one, a missing 256-entry table does not rule out zlib-compatible output.

Evidence & references

  • richgel999/miniz commit 2948eebafc5b9f1c69bebed80333e403a09bd62d: miniz.c, miniz.h, miniz_tinfl.c. Read only; not compared with a compiled binary.