Skip to content

fix(arcup): accept checksum files without a trailing newline - #243

Open
osr21 wants to merge 1 commit into
circlefin:mainfrom
osr21:fix/arcup-checksum-no-trailing-newline
Open

fix(arcup): accept checksum files without a trailing newline#243
osr21 wants to merge 1 commit into
circlefin:mainfrom
osr21:fix/arcup-checksum-no-trailing-newline

Conversation

@osr21

@osr21 osr21 commented Aug 8, 2026

Copy link
Copy Markdown

What

verify_checksum_file() decided whether a checksum file was empty from the exit status of:

read -r expected_checksum expected_name < "$checksum_path"

read returns a non-zero status when it reaches EOF before encountering a newline — even though it has already assigned the variables. So a .sha256 file whose single line has no trailing newline (valid, and produced by several non-GNU checksum tools or by manual editing) was rejected with Checksum file is empty, aborting an otherwise-correct install.

Fix

Decide emptiness from the parsed hash rather than from read's exit status:

read -r expected_checksum expected_name < "$checksum_path" || true
if [[ -z "$expected_checksum" ]]; then
    error "Checksum file is empty: $checksum_path"
fi

A genuinely empty file still produces an empty $expected_checksum and is still rejected, so the empty-file guard is preserved.

Repro

printf '%s  archive.tar.gz' "$(sha256sum archive.tar.gz | cut -d' ' -f1)" > archive.tar.gz.sha256  # no trailing newline
# before: aborts with "Checksum file is empty"
# after:  verifies normally

Tests

Extends test_checksum_validation in arcup/test_arcup.sh with two cases:

  • a valid checksum file without a trailing newline now passes;
  • a genuinely empty checksum file is still rejected.

Both fail on the current arcup and pass with this change. Full bash arcup/test_arcup.sh suite is green.

Notes

Current release .sha256 assets do end in a newline, so this is a latent-robustness fix in the checksum-verification path rather than an active break — but arcup shouldn't refuse a checksum file it verifies correctly simply because of a missing trailing newline.

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.
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.

1 participant