Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify offset 0 as invalid and specify required fixup behavior #3824

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/decompressor_accepted_invalid_data.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Decompressor Accepted Invalid Data
==================================

This document describes the behavior of the reference decompressor in cases
where it accepts an invalid frame instead of reporting an error.

Zero offsets converted to 1
---------------------------
If a sequence is decoded with `literals_length = 0` and `offset_value = 3`
while `Repeated_Offset_1 = 1`, the computed offset will be `0`, which is
invalid.

The reference decompressor will process this case as if the computed
offset was `1`, including inserting `1` into the repeated offset list.
5 changes: 4 additions & 1 deletion doc/zstd_compression_format.md
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,10 @@ There is an exception though, when current sequence's `literals_length = 0`.
In this case, repeated offsets are shifted by one,
so an `offset_value` of 1 means `Repeated_Offset2`,
an `offset_value` of 2 means `Repeated_Offset3`,
and an `offset_value` of 3 means `Repeated_Offset1 - 1_byte`.
and an `offset_value` of 3 means `Repeated_Offset1 - 1`.

In the final case, if `Repeated_Offset1 - 1` evaluates to 0, then the
data is considered corrupted.

For the first block, the starting offset history is populated with following values :
`Repeated_Offset1`=1, `Repeated_Offset2`=4, `Repeated_Offset3`=8,
Expand Down