From d50d17657394bcb9459aa1c1c36325fb902ce8d4 Mon Sep 17 00:00:00 2001 From: osr21 Date: Sat, 8 Aug 2026 19:34:12 +0000 Subject: [PATCH 1/2] fix(arcup): accept checksum files without a 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. --- arcup/arcup | 7 ++++++- arcup/test_arcup.sh | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arcup/arcup b/arcup/arcup index 3590cd36..999bc2b2 100755 --- a/arcup/arcup +++ b/arcup/arcup @@ -656,7 +656,12 @@ 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` returns non-zero when it hits EOF before a newline, even though it + # still populates the variables. A checksum file whose single line has no + # trailing newline is valid, so 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 diff --git a/arcup/test_arcup.sh b/arcup/test_arcup.sh index 49021191..32f7033d 100755 --- a/arcup/test_arcup.sh +++ b/arcup/test_arcup.sh @@ -119,6 +119,15 @@ 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" + + # A checksum file whose only line has no trailing newline is still valid. + printf '%s %s' "$checksum" "$archive_name" > "$checksum_file" + verify_checksum_file "$archive" "$checksum_file" "$archive_name" + pass "checksum file without trailing newline passes" + + # A genuinely empty checksum file must still be rejected. + : > "$checksum_file" + expect_fail "empty checksum file fails" verify_checksum_file "$archive" "$checksum_file" "$archive_name" } test_download_error_lists_assets() { From 01694c42966a1c1142ed8e0203517a24269934e9 Mon Sep 17 00:00:00 2001 From: osr21 Date: Sun, 9 Aug 2026 18:47:33 +0000 Subject: [PATCH 2/2] test(arcup): cover mismatched checksum without trailing newline --- arcup/test_arcup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arcup/test_arcup.sh b/arcup/test_arcup.sh index 32f7033d..cb56b648 100755 --- a/arcup/test_arcup.sh +++ b/arcup/test_arcup.sh @@ -128,6 +128,11 @@ test_checksum_validation() { # A genuinely empty checksum file must still be rejected. : > "$checksum_file" expect_fail "empty checksum file fails" verify_checksum_file "$archive" "$checksum_file" "$archive_name" + + # A wrong hash without a trailing newline must still fail the comparison, + # not slip through the emptiness check. + printf '%s %s' "0000000000000000000000000000000000000000000000000000000000000000" "$archive_name" > "$checksum_file" + expect_fail "mismatched checksum without trailing newline fails" verify_checksum_file "$archive" "$checksum_file" "$archive_name" } test_download_error_lists_assets() {