fix(arcup): accept checksum files without a trailing newline - #243
Open
osr21 wants to merge 1 commit into
Open
Conversation
verify_checksum_file() decided emptiness from the exit status of `read -r expected_checksum expected_name < "$checksum_path"`. `read` returns non-zero when it reaches EOF before a newline, even though it has already populated the variables. A .sha256 whose single line lacks a trailing newline is valid, but arcup rejected it with "Checksum file is empty", aborting a correct install. Decide emptiness from the parsed hash instead of read's exit status. A genuinely empty file still yields an empty hash and is still rejected. Adds regression tests covering the no-trailing-newline and empty cases.
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.
What
verify_checksum_file()decided whether a checksum file was empty from the exit status of:readreturns a non-zero status when it reaches EOF before encountering a newline — even though it has already assigned the variables. So a.sha256file whose single line has no trailing newline (valid, and produced by several non-GNU checksum tools or by manual editing) was rejected withChecksum file is empty, aborting an otherwise-correct install.Fix
Decide emptiness from the parsed hash rather than from
read's exit status:A genuinely empty file still produces an empty
$expected_checksumand is still rejected, so the empty-file guard is preserved.Repro
Tests
Extends
test_checksum_validationinarcup/test_arcup.shwith two cases:Both fail on the current
arcupand pass with this change. Fullbash arcup/test_arcup.shsuite is green.Notes
Current release
.sha256assets do end in a newline, so this is a latent-robustness fix in the checksum-verification path rather than an active break — butarcupshouldn't refuse a checksum file it verifies correctly simply because of a missing trailing newline.