diff --git a/checksum.go b/checksum.go index 986b23137..958bbede5 100644 --- a/checksum.go +++ b/checksum.go @@ -272,7 +272,10 @@ func (c *Client) checksumFromFile(ctx context.Context, checksumURL string, check return nil, fmt.Errorf( "Error reading checksum file: %s", err) } - break + if line == "" { + break + } + // parse the line, if we hit EOF, but the line is not empty } checksum, err := parseChecksumLine(line) if err != nil || checksum == nil { diff --git a/get_test.go b/get_test.go index 0ee215aaa..c240f7051 100644 --- a/get_test.go +++ b/get_test.go @@ -570,13 +570,18 @@ func TestGetFile_checksum_from_file(t *testing.T) { true, false, }, - // sha512 { "?checksum=file:" + checksums + "/CHECKSUM_sha256_gpg", true, false, }, + { + // checksum file does not have EOL, ends line with EOF + "?checksum=file:" + httpChecksums.URL + "/sha512-p-EOF.sum", + true, + false, + }, } for _, tc := range cases { diff --git a/testdata/checksum-file/sha512-p-EOF.sum b/testdata/checksum-file/sha512-p-EOF.sum new file mode 100644 index 000000000..2c72e8817 --- /dev/null +++ b/testdata/checksum-file/sha512-p-EOF.sum @@ -0,0 +1 @@ +060a8cc41c501e41b4537029661090597aeb4366702ac3cae8959f24b2c49005d6bd339833ebbeb481b127ac822d70b937c1637c8d0eaf81b6979d4c1d75d0e1 \ No newline at end of file