You are not logged in.
sha256sum -c prints OK for a failed checksum when the entry is not the first entry on the list. To reproduce run:
echo "123" > 1
echo "1234" > 2
echo "abc" > 3
sha256sum 1 2 3 > sums.sha256
echo "q" > 2
sha256sum -c sums.sha256
tail -n 2 sums.sha256 | sha256sum -c
The above script yields:
1: OK
2: OK
3: OK
sha256sum: WARNING: 1 computed checksum did NOT match
2: FAILED
3: OK
sha256sum: WARNING: 1 computed checksum did NOT match
I am using sha256sum (GNU coreutils) 9.2. Anyone else have the same problem? Is there a bug report?
Last edited by patenteng (2023-03-23 09:56:50)
Offline
Cross-posting my response from your reddit post:
Likely a bug in coreutils 9.2. If you check the source:
if (match)
matched_checksums = true;
else
++n_mismatched_checksums;
if (!status_only)
{
/* ... */
if ( ! matched_checksums)
printf (": %s\n", _("FAILED"));
else if (!quiet)
printf (": %s\n", _("OK"));
}
The printed output depends on matched_checksums which is set to true if the digest of a file matches, but never to false if it doesn't. It's only set to false once by default, at the beginning of the routine, before the file loop.
Seems the logic was changed in this commit for 9.2, and the bug doesn't occur in 9.1 (I just tested)
Offline