Skip to content

config: return an error when gzip content is incomplete - #41

Open
shubham76-dev wants to merge 1 commit into
flatcar:mainfrom
shubham76-dev:fix-gzip-decode-error
Open

config: return an error when gzip content is incomplete#41
shubham76-dev wants to merge 1 commit into
flatcar:mainfrom
shubham76-dev:fix-gzip-decode-error

Conversation

@shubham76-dev

Copy link
Copy Markdown

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.

gzip.NewReader only 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:

DecodeContent(truncated, "gzip")  ->  err = <nil>, 20 bytes decoded

This reaches two places: CloudConfig.Decode() stores the partial content, which then gets written
to disk, and checkEncoding() in config/validate uses the same helper, so -validate reports the
config 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

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>
@shubham76-dev
shubham76-dev requested a review from a team as a code owner August 5, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coreos-cloudinit: incomplete gzip content in write_files is decoded silently

1 participant