Fix an error in how cksum parses checksum files#11553
Draft
frenchua wants to merge 1 commit intouutils:mainfrom
Draft
Fix an error in how cksum parses checksum files#11553frenchua wants to merge 1 commit intouutils:mainfrom
frenchua wants to merge 1 commit intouutils:mainfrom
Conversation
When cksum (or sha256sum, etc...) attempts to parse chekcusm files in
the "tagged output format" and it encounters the string "((", it
crashes due to an error in how it parses the checksum file. GNU
coreutils, by contrast, correctly recognizes this string as a syntax
error and ignores the line.
|
GNU testsuite comparison: |
Contributor
|
could you please add a test to make sure we don't regress in the future? |
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.
When cksum (or sha256sum, etc...) is called with the
-coption, and it attempts to parse cheksum files in the "tagged output format" and it encounters the string "((", it crashes due to an error in how it parses the checksum file. GNU coreutils, by contrast, correctly recognizes this line as a syntax error and ignores the line.This is due to the following two lines of code in the
parse_algo_basedfunction invalidate.rs:If the checksum file contains two consecutive left parentheses, then
par_idxis equal to zero and sorest[par_idx - 1]evaluates torest[-1]which causes the program to crash.I have added a check to make sure that
par_idxis greater than zero because, In my view, the string '((' appearing in a checksum file should be considered a syntax error and the line ignored, just as it does in the GNU cksum/sha256sum program).