From aaabb5c3780f719077d874cb687527f2fc17baf4 Mon Sep 17 00:00:00 2001 From: Uzair Rehman Date: Wed, 23 Sep 2026 14:15:19 +0500 Subject: [PATCH] fix(arcup): verify_checksum_file rejects valid checksum files without a trailing newline read(1) returns a non-zero exit status when it hits EOF before a delimiter, even though it still populates the target variables from the partial final line. verify_checksum_file treated that non-zero status as "file is empty" and aborted, so any .sha256 file lacking a trailing newline (e.g. produced by some tools' sha256sum output) was rejected even though it contained a valid checksum. Check whether expected_checksum ended up empty instead of relying on read's exit status, which still correctly rejects a genuinely empty checksum file. Fixes #420, Fixes #448 Co-Authored-By: Claude Sonnet 5 --- arcup/arcup | 4 +++- arcup/test_arcup.sh | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arcup/arcup b/arcup/arcup index 3590cd36..7cb7e568 100755 --- a/arcup/arcup +++ b/arcup/arcup @@ -656,7 +656,9 @@ verify_checksum_file() { local archive_name="$3" local expected_checksum expected_name actual_checksum - if ! read -r expected_checksum expected_name < "$checksum_path"; then + read -r expected_checksum expected_name < "$checksum_path" || true + + if [[ -z "$expected_checksum" ]]; then error "Checksum file is empty: $checksum_path" fi diff --git a/arcup/test_arcup.sh b/arcup/test_arcup.sh index 49021191..2cc5a376 100755 --- a/arcup/test_arcup.sh +++ b/arcup/test_arcup.sh @@ -119,6 +119,13 @@ test_checksum_validation() { printf '%s other-asset.tar.gz\n' "$checksum" > "$checksum_file" expect_fail "checksum filename mismatch fails" verify_checksum_file "$archive" "$checksum_file" "$archive_name" + + printf '%s %s' "$checksum" "$archive_name" > "$checksum_file" + verify_checksum_file "$archive" "$checksum_file" "$archive_name" + pass "valid checksum file without trailing newline passes" + + printf '' > "$checksum_file" + expect_fail "empty checksum file fails" verify_checksum_file "$archive" "$checksum_file" "$archive_name" } test_download_error_lists_assets() {