Return failure on comment mismatch in CLI decompression#1453
Merged
copybara-service[bot] merged 4 commits intogoogle:masterfrom Apr 15, 2026
Merged
Conversation
The final comment verification check in DecompressFile() detects when comment_state is not COMMENT_OK but unconditionally returns BROTLI_TRUE. This causes the -C (comment verification) flag to accept streams with missing or mismatched comments, keeping the output file and exiting 0. Add the missing return BROTLI_FALSE inside the mismatch branch so that comment verification failures are properly propagated to the caller.
Collaborator
|
Awesome, thanks! |
Contributor
Author
|
Hey if i report this in vrp google will this qualify? |
Collaborator
|
Likely not. This feature was requested by community,... but it seems to be not actually used (otherwise problem should have been already reported). |
eustas
approved these changes
Apr 15, 2026
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.
Summary
return BROTLI_FALSEin the final comment verification check ofDecompressFile()(c/tools/brotli.c:1290-1297)-Cflag now correctly rejects streams with missing or mismatched commentsThe Bug
In
DecompressFile(), the final comment state check at the end of successful decoding detects a mismatch but does not act on it:The error message is printed to stderr, but the function returns
BROTLI_TRUEregardless. The callerDecompressFiles()then keeps the output file and the process exits 0.When this triggers
The early check (line 1231) only catches
COMMENT_BADmid-stream. The final check catches states that the early check misses:COMMENT_BADCOMMENT_INITTRUECOMMENT_READTRUEA tampered or re-encoded stream that strips the metadata block bypasses verification entirely.
Impact
Scripts relying on
-Cto validate stream integrity/fingerprint accept tampered streams:The Fix
One-line change — add
return BROTLI_FALSEinside the mismatch branch:This is consistent with every other error path in the function (lines 1237, 1246, 1280, 1307).
Test plan
-C <comment>, decode with matching-C→ succeeds (no change)-C <comment>, decode with wrong-C→ now fails with exit code 1-C, decode with-C <comment>→ now fails (no metadata in stream,COMMENT_INITat final check)-C→ succeeds (no change,comment_stateinitialized toCOMMENT_OK)