config: return an error when gzip content is incomplete - #41
Open
shubham76-dev wants to merge 1 commit into
Open
config: return an error when gzip content is incomplete#41shubham76-dev wants to merge 1 commit into
shubham76-dev wants to merge 1 commit into
Conversation
DecodeGzipContent ignored the error from buf.ReadFrom, so a write_files entry with a truncated or corrupted gzip payload decoded to partial content and was reported as successful. The same helper backs the -validate path, so such a config also passed validation. Add the missing error check and cover the decode helpers, which had no tests. Signed-off-by: Shubham Raj <shubh07601@gmail.com>
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.
DecodeGzipContentignored the error frombuf.ReadFrom, so awrite_filesentry with a truncatedor corrupted gzip payload decoded to partial content and was reported as successful.
gzip.NewReaderonly reads the header, so an incomplete stream passes that check and fails later,while reading the body. With a 6615-byte payload cut in the middle of the deflate stream:
This reaches two places:
CloudConfig.Decode()stores the partial content, which then gets writtento disk, and
checkEncoding()inconfig/validateuses the same helper, so-validatereports theconfig as valid.
The decode helpers had no tests, so this adds a table test for the supported encodings plus the
truncated and corrupted-checksum cases. Both new cases fail without the change.
Fixes flatcar/Flatcar#2292