Bug 267722 - sha256sum returns failure with a valid checksum
Summary: sha256sum returns failure with a valid checksum
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.1-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: Kyle Evans
URL: https://reviews.freebsd.org/D37374
Keywords:
: 264623 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-11-12 00:34 UTC by f451
Modified: 2023-08-10 14:40 UTC (History)
4 users (show)

See Also:
kevans: mfc-stable13+
kevans: mfc-stable12+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description f451 2022-11-12 00:34:50 UTC
system:
FreeBSD 13.1-STABLE #5 stable/13-n252944-e52aaa644ce1: Mon Nov  7 17:22:45 GMT 202 amd64

$ sha256sum -c CHECKSUM.SHA256-FreeBSD-13.1-RELEASE-amd64 FreeBSD-13.1-RELEASE-amd64-dvd1.iso.xz
...
FreeBSD-13.1-RELEASE-amd64-dvd1.iso.xz: FAILED
sha256sum: WARNING: 1 computed checksums did NOT match
...

contrast to:

$ cat CHECKSUM.SHA256-FreeBSD-13.1-RELEASE-amd64 | grep FreeBSD-13.1-RELEASE-amd64-dvd1.iso.xz
...
SHA256 (FreeBSD-13.1-RELEASE-amd64-dvd1.iso.xz) = 8b22dd325280c811725ca8178d8408d7a235161fbb1650b2a369b6e8acbaeaf8

$ sha256sum FreeBSD-13.1-RELEASE-amd64-dvd1.iso.xz
8b22dd325280c811725ca8178d8408d7a235161fbb1650b2a369b6e8acbaeaf8  FreeBSD-13.1-RELEASE-amd64-dvd1.iso.xz

Tried the equivalent with the same files on OpenBSD72

% sha256 -c CHECKSUM.SHA256-FreeBSD-13.1-RELEASE-amd64

(lots of no file or directory as the checksum file is for all media not just the dvd iso.xz)

(SHA256) FreeBSD-13.1-RELEASE-amd64-dvd1.iso.xz: OK
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-02-13 06:32:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8d78a0d331ec2c168efe6cb85bbc2da86e9a6124

commit 8d78a0d331ec2c168efe6cb85bbc2da86e9a6124
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-02-13 06:32:38 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-02-13 06:32:38 +0000

    md5: fix *sum -c with missing files

    If we fail to open one of the files in the file listing, we still need
    to advance `rec` along with `argv` so that the checksum we're checking
    against lines up with the file we're hashing.

    Tests added both for the -c flag, as well as the -b and -t modes of
    the *sum programs.

    PR:             267722
    Reviewed by:    emaste (earlier version)
    MFC after:      3 days
    Differential Revision:  https://reviews.freebsd.org/D37374

 sbin/md5/md5.c                       |  2 +
 sbin/md5/tests/Makefile              |  4 +-
 sbin/md5/tests/md5_test.sh (new)     | 82 ++++++++++++++++++++++++++++++++++++
 sbin/md5/tests/sum_a.in (new)        |  1 +
 sbin/md5/tests/sum_b.in (new)        |  1 +
 sbin/md5/tests/sum_c.in (new)        |  1 +
 sbin/md5/tests/sum_sums.digest (new) |  3 ++
 7 files changed, 93 insertions(+), 1 deletion(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-02-16 03:35:22 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9eb694146a19bd0ee7439f6cab030a8d5c273977

commit 9eb694146a19bd0ee7439f6cab030a8d5c273977
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-02-13 06:32:38 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-02-16 03:29:46 +0000

    md5: fix *sum -c with missing files

    If we fail to open one of the files in the file listing, we still need
    to advance `rec` along with `argv` so that the checksum we're checking
    against lines up with the file we're hashing.

    Tests added both for the -c flag, as well as the -b and -t modes of
    the *sum programs.

    PR:             267722
    Reviewed by:    emaste (earlier version)

    (cherry picked from commit 8d78a0d331ec2c168efe6cb85bbc2da86e9a6124)

 sbin/md5/md5.c                       |  2 +
 sbin/md5/tests/Makefile              |  4 +-
 sbin/md5/tests/md5_test.sh (new)     | 82 ++++++++++++++++++++++++++++++++++++
 sbin/md5/tests/sum_a.in (new)        |  1 +
 sbin/md5/tests/sum_b.in (new)        |  1 +
 sbin/md5/tests/sum_c.in (new)        |  1 +
 sbin/md5/tests/sum_sums.digest (new) |  3 ++
 7 files changed, 93 insertions(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-02-16 04:54:35 UTC
A commit in branch releng/13.2 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5ad8ebc3a3a51b6726364788e42f49d36b4048d3

commit 5ad8ebc3a3a51b6726364788e42f49d36b4048d3
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-02-13 06:32:38 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-02-16 04:53:39 +0000

    md5: fix *sum -c with missing files

    If we fail to open one of the files in the file listing, we still need
    to advance `rec` along with `argv` so that the checksum we're checking
    against lines up with the file we're hashing.

    Tests added both for the -c flag, as well as the -b and -t modes of
    the *sum programs.

    PR:             267722
    Reviewed by:    emaste (earlier version)
    Approved by:    re (cperciva)

    (cherry picked from commit 8d78a0d331ec2c168efe6cb85bbc2da86e9a6124)
    (cherry picked from commit 9eb694146a19bd0ee7439f6cab030a8d5c273977)

 sbin/md5/md5.c                       |  2 +
 sbin/md5/tests/Makefile              |  4 +-
 sbin/md5/tests/md5_test.sh (new)     | 82 ++++++++++++++++++++++++++++++++++++
 sbin/md5/tests/sum_a.in (new)        |  1 +
 sbin/md5/tests/sum_b.in (new)        |  1 +
 sbin/md5/tests/sum_c.in (new)        |  1 +
 sbin/md5/tests/sum_sums.digest (new) |  3 ++
 7 files changed, 93 insertions(+), 1 deletion(-)
Comment 4 Kyle Evans freebsd_committer freebsd_triage 2023-02-16 04:55:04 UTC
Thanks for the report!
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-02-16 04:58:37 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a80643d2a94fc55b7e2567d63d66c0c3cd17a830

commit a80643d2a94fc55b7e2567d63d66c0c3cd17a830
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2023-02-13 06:32:38 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-02-16 04:57:49 +0000

    md5: fix *sum -c with missing files

    If we fail to open one of the files in the file listing, we still need
    to advance `rec` along with `argv` so that the checksum we're checking
    against lines up with the file we're hashing.

    Tests added both for the -c flag, as well as the -b and -t modes of
    the *sum programs.

    PR:             267722
    Reviewed by:    emaste (earlier version)

    (cherry picked from commit 8d78a0d331ec2c168efe6cb85bbc2da86e9a6124)

 sbin/md5/md5.c                       |  2 +
 sbin/md5/tests/Makefile              |  4 +-
 sbin/md5/tests/md5_test.sh (new)     | 82 ++++++++++++++++++++++++++++++++++++
 sbin/md5/tests/sum_a.in (new)        |  1 +
 sbin/md5/tests/sum_b.in (new)        |  1 +
 sbin/md5/tests/sum_c.in (new)        |  1 +
 sbin/md5/tests/sum_sums.digest (new) |  3 ++
 7 files changed, 93 insertions(+), 1 deletion(-)
Comment 6 Ed Maste freebsd_committer freebsd_triage 2023-08-10 14:40:39 UTC
*** Bug 264623 has been marked as a duplicate of this bug. ***