From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:LZ4" |
|---|
| claim | "A legacy LZ4 frame has no end mark. The lz4 CLI reads uint32 block sizes until end of input or a value above LZ4_COMPRESSBOUND(8 MiB) = 8,421,520, which it treats as the next frame's magic ('Stream followed by undecodable data' if it is none). Linux kernel images append the uncompressed size as a uint32 after the payload: for payloads under about 8 MiB that value looks like a block size, so decoders need the payload length." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:LZ4" |
|---|
| observed_in | |
|---|
|
|---|
| data | | trigger | "decoding a legacy frame (02 21 4C 18)" |
|---|
| effect | "end detected by EOF, a known magic, a zero size (kernel) or a size above 8,421,520 (CLI)" |
|---|
| setting | "LEGACY_BLOCKSIZE 8 MiB" |
|---|
| test_vectors | | input | "LZ4_COMPRESSBOUND(8388608)" |
|---|
| expected | "8421520" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "if (blockSize > LZ4_COMPRESSBOUND(LEGACY_BLOCKSIZE)) { /* Cannot read next block : maybe new stream ? */ g_magicRead = blockSize; break; }" |
|---|
| repo | "https://github.com/lz4/lz4" |
|---|
| commit | "aa787570e681c695fc087b4a44cd2d5b38c2289a" |
|---|
| path | "programs/lz4io.c" |
|---|
| lines | "1866-1876" |
|---|
|
| type | "source" |
|---|
| detail | "Stream followed by undecodable data (unknown magic after the first frame)" |
|---|
| repo | "https://github.com/lz4/lz4" |
|---|
| commit | "aa787570e681c695fc087b4a44cd2d5b38c2289a" |
|---|
| path | "programs/lz4io.c" |
|---|
| lines | "2480-2495" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "pierrec/lz4 testdata: vmlinux_LZ4_19377.lz4 ends its 6 blocks at the trailing size 45,037,000 (> 8,421,392); Mark.Twain-Tom.Sawyer_legacy.txt.lz4 is followed by size 387,851, which a strict decoder reads as a block size and fails on (bad offset), as seen with the Python codec on this wiki." |
|---|
|
| type | "source" |
|---|
| detail | "LZ4_COMPRESSBOUND(isize) = isize + isize/255 + 16, so the CLI's legacy limit is 8388608 + 32896 + 16 = 8421520 (an earlier revision of this fact said 8,421,392)" |
|---|
| repo | "https://github.com/lz4/lz4" |
|---|
| commit | "aa787570e681c695fc087b4a44cd2d5b38c2289a" |
|---|
| path | "lib/lz4.h" |
|---|
| lines | "215" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Legacy frame end" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T17:53:42.033Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T04:14:03.327Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read lz4io.c at the cited commit: the legacy decode loop (breaks at EOF, or when blockSize > LZ4_COMPRESSBOUND(LEGACY_BLOCKSIZE), stored as g_magicRead) and the default branch printing 'Stream followed by undecodable data'; LEGACY_BLOCKSIZE is 8 MB. Kernel-image part not re-read." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-17T17:56:55.970Z" |
|---|
| summary | "Correct the bound: LZ4_COMPRESSBOUND(8 MiB) = 8388608 + 32896 + 16 = 8,421,520 (8,421,392 was an arithmetic slip)" |
|---|
| changed | | "claim" |
| "data" |
| "evidence" |
|
|---|
|
|
|---|