Skip to content

arcup: download_file's error handling is silently defeated on curl 8.14.0/8.14.1 #309

Description

@batuhankocyigit

Summary

Split off from review discussion on #304.

download_file in arcup/arcup relies on curl's exit code to detect
failed downloads:

if ! curl_with_headers -#fL --max-time 900 -o "$output_path" "$url"; then
    rm -f "$output_path"
    download_error "$tag" "$filename" "$url"
fi

curl_with_headers includes CURL_RETRY_ARGS=(--retry 3 --retry-delay 2 --connect-timeout 15). On curl 8.14.0 and 8.14.1, combining --retry with
--fail causes curl to exit 0 even on a 404 (upstream bug, see
curl/curl#17554 — fixed in later releases; --retry 0 or omitting
--retry exits 22 correctly on those versions).

Reproduced by running the arcup test suite's e2e test against main on a
box with curl 8.14.1: instead of download_error's intended message, the
script fails later with Checksum file is empty: … — a much less useful
error for whoever hits it.

Impact

The install still fails closed (checksum verification catches the empty/
missing file downstream), so this isn't a security issue — just a
misleading-error-message issue on a curl line version that ships in
current distros and nixpkgs.

Suggested fix

Add an explicit non-empty-file check after the curl call in download_file
(and download_file_with_github_api, which has the same pattern),
independent of curl's exit code:

if ! curl_with_headers -#fL --max-time 900 -o "$output_path" "$url" || [[ ! -s "$output_path" ]]; then
    rm -f "$output_path"
    download_error "$tag" "$filename" "$url"
fi

This immunizes the check against the curl version-specific behavior
rather than depending on the exit code alone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions