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

From ReverseEngineering.wiki
Library
Developer Google
Platforms any (C++11), SSE4.2/NEON paths
Versions 1.3.1 in CMakeLists.txt at the pinned commit
License BSD-3-Clause
Website https://github.com/google/snappy
On this wiki Facts · Code · Notes · Topics

Google's Snappy compression library (C++, BSD-3-Clause, version 1.3.1 in its CMake project): snappy::Compress / RawUncompress, snappy_* C API, no embedded tables of note; identified by exports and the framing magic.

Overview

Snappy is embedded in LevelDB/RocksDB, Chromium, Hadoop/Parquet connectors, game engines and network software, usually statically linked. See Format:Snappy for the byte layout.

Identification

  • C API in snappy-c.h: snappy_compress, snappy_uncompress, snappy_max_compressed_length, snappy_uncompressed_length, snappy_validate_compressed_buffer. The C++ names are in namespace snappy (snappy::RawCompress, snappy::RawUncompress, snappy::Uncompress, snappy::MaxCompressedLength, snappy::IsValidCompressedBuffer).
  • There is no run-time version function and no banner string; the version (SNAPPY_MAJOR/MINOR/PATCHLEVEL, 1.3.1) is in snappy-stubs-public.h and only reaches a binary through your own use of the macros. Library sonames come from CMake: libsnappy.so.1.
  • There is no large constant table. The decoder has a small tag-to-length table (char_table, 256 uint16 entries in snappy.cc) and a table of CRC-32C only exists in the framing layer of other implementations (the reference library does not implement the framing format).
  • The compressor hashes four bytes with the multiplier 0x1E35A7BD (kMagic in snappy.cc: (bytes * 0x1e35a7bd) >> shift).
  • Block-size constant: kBlockSize 1 << 16 (65536).

Pitfalls

  • Because the reference library has no framing code, a 'sNaPpY' string in a binary points to a port or a language binding (python-snappy, snappy-java, golang/snappy, snzip), not to libsnappy itself.
  • kMagic 0x1e35a7bd is the hash multiplier at snappy.cc line 172 (SSE4.2 path); other code paths use 2654435761 (0x9E3779B1) and 58295818150454627 (64-bit).

Code & repositories

See the linked repository.

  • https://github.com/google/snappy @ 9c28114a38866f6deeaa826db918293bc28ae410 · license: BSD-3-Clause (declared by the contributor; GitHub's detector did not recognize COPYING)
    Reference Snappy source with format_description.txt and framing_format.txt
    Tested on: source read, not run: source only · checked 2026-10-18; last activity 2026-09-18