Repository navigation
Conversation
The format was cached as soon as a line matched a parser syntactically, before its digest was validated. A free-text line such as "2024 release" could therefore switch how the following lines were read, so the listed files were never opened. The format is now recorded only for lines that are not improperly formatted. Fixes uutils#15770
This branch has not been deployed
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.
Fixes #15770
LineInfo::parsestored the detected line format incached_line_formatas soon as a line matched a parser, before the digest was validated. A free-text line such as2024 releasematched the single-space parser, was then rejected as improperly formatted, but had already made single-space the format for the rest of the file. Every following<digest> nameline was read as the filename(with a leading space), so the files that were actually listed were never opened. With a file namedanext to a tampereda,md5sum --checkprinted' a': OKand exited 0. A line likeChecksums for releasedid the same the other way round and dropped valid single-space lines.process_checksum_linenow parses into a local copy of the cache and writes it back only when the line is not improperly formatted.LineInfo::parseand its signature are unchanged. Lines that are well formed but fail later (DigestMismatch, missing or unreadable file) still set the format, as before.Tests: three unit tests in
validate.rsand onemd5sumintegration test, appended at the end oftest_md5sum.rs. The two format-selection unit tests and the integration test fail on current main and pass with this change. The third unit test is a guard for the unchanged behaviour. I also ran the issue's example with a build from main and one with this change: before,md5sum --checkreported the tampered files asOK(exit 0); after, it reportsa: FAILED,c: FAILEDand exits 1.Ran locally:
cargo fmt --all -- --check,cargo clippy --all-targets -- -D warningsat the workspace root,cargo test -p uucore --features checksum checksum::validate, and thetest_md5sum,test_sha256sumandtest_cksumintegration tests (448 passed). Tested on macOS only; spell-check was not run.