Fix Config::load reading one byte past the end of the config - #131
Open
alexey-milovidov wants to merge 1 commit into
Open
Fix Config::load reading one byte past the end of the config#131alexey-milovidov wants to merge 1 commit into
alexey-milovidov wants to merge 1 commit into
Conversation
`Config::save` writes `confSize = c - c0`, i.e. the total size of the serialized config including the one-byte length prefix. In `Config::load` the end pointer was computed as `c + confSize` after the prefix byte had already been consumed, so it pointed one byte past the real end of the config blob. The `if (c < c1)` guards that read the optional trailing fields then use a boundary that is one byte too far. For a config that does not contain all of the trailing fields (e.g. data produced by a build with fewer fields) this makes `load` read one field past the end of the config. Compute the end as `c0 + confSize` instead.
This was referenced Sep 1, 2026
ayzk
added a commit
that referenced
this pull request
Sep 1, 2026
Bug fixes only: no compressed-format change and no interface signature change. Covers the reviewed content of #131, #133, #134, #135, #137, #138 and #139, plus the findings ported from the fz branch. #132 is only partly covered -- see the PR body for the four exclusions and the measurement behind each. 31 dataset x algorithm x error-bound combinations are byte-identical to master, and every master-produced file still decompresses to the same bytes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Config::savewrites the config size asconfSize = c - c0, i.e. the total size of the serialized config including the one-byte length prefix it reserves at the start.In
Config::load, the end pointer is computed asc + confSizeafter the prefix byte has already been read, so it ends up one byte past the real end of the config blob:The
if (c < c1)guards that read the optional trailing fields then use a boundary that is one byte too far. For a config that does not contain all of the trailing fields, this makesloadread one field past the end of the config.Fix
Compute the end of the config relative to its start:
No format change; this only corrects the in-memory end pointer used by
load.Context
Found while integrating SZ3 as an experimental compression codec in ClickHouse: ClickHouse/ClickHouse#108788