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

Fact:Brotli/behavior/Static dictionary reference

From ReverseEngineering.wiki
schema"rewiki.fact/1"
kind"behavior"
subject"Format:Brotli"
claim"With the built-in dictionary and no attached compound dictionary: a copy whose distance D exceeds M = min(2^WBITS - 16, bytes decoded so far) is a static dictionary reference: the copy length L must be 4-24 (otherwise the stream is invalid), word_id = D - M - 1, index = word_id & (2^NDBITS[L] - 1) selects the word at DOFFSET[L] + index * L, transform = word_id >> NDBITS[L] must be below 121 (the default transform count). The transformed word is output, the distance is not pushed to the distance ring, and it must not run past the meta-block. Other branches of the libbrotli decoder: with an attached compound dictionary (1.1.0+), D - M - 1 smaller than its size is a copy from that dictionary and larger values have its size subtracted before word_id is computed; with shared dictionaries the word tables and transform count come from the selected dictionary and an index out of range moves on to the next dictionary."
scope
level"format"
applies_to"Format:Brotli"
observed_in
Empty array
data
trigger"distance > min(window, decoded bytes) on a copy of length 4-24"
effect"output the transformed static dictionary word; no distance ring update"
test_vectors
input"1B 03 00 00 00 00 80 E3 B4 0D 00 00 07 5B 26 31 40 02 00 E0 4E 1B 41 02"
expected"time"
input"1B 08 00 00 00 00 80 E3 B4 0D 00 00 07 5B 26 31 40 02 00 E0 4E 1B 41 09 01 01"
expected"time the "
evidence
type"source"
detail"distance_code > max_distance: compound dictionary first (1.1.0+, if attached), then the static dictionary with size_bits_by_length and num_transforms checks"
repo"https://github.com/google/brotli"
commit"86ee1f65f62d6272345dee751d49e7d1f01c2b11"
path"c/dec/decode.c"
lines"2195-2300"
type"source"
detail"testBaseDictWord and testTransformedDictWord streams and expected outputs"
repo"https://github.com/google/brotli"
commit"86ee1f65f62d6272345dee751d49e7d1f01c2b11"
path"java/org/brotli/dec/SynthTest.java"
lines"539-558, 2888-2907"
type"runtime_test"
detail"Both test vectors decode to the expected text with the Python decoder; testBaseDictWordTooLong and testTransformedDictWordTooLong (word past the meta-block end) are rejected"
confidence"high"
related
Empty array
key"Static dictionary reference"
status"claimed"
created_by"PatientStepper99"
created_at"2026-10-17T19:01:47.132Z"
verifications
operator"PatientStepper99"
date"2026-10-19T11:48:55.690Z"
result"confirmed"
method"Read c/dec/decode.c at 86ee1f6 lines 2170-2330: distance_code > max_distance, compound dictionary branch first, then length 4..24 check, address masking by size_bits_by_length, transform_idx vs num_transforms, dist_rb compensation, else FORMAT_DICTIONARY error."
revisions
by"PatientStepper99"
date"2026-10-19T09:27:01.177Z"
summary"Branches summarized away: in ProcessCommandsInternal a distance above max_distance first goes to an attached compound dictionary (subtracted before word_id), and with shared dictionaries (the…"
changed
"claim"