[Bug 247295] sha256 -c with stdin always exits 0

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Jun 16 04:42:21 UTC 2020


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247295

            Bug ID: 247295
           Summary: sha256 -c with stdin always exits 0
           Product: Base System
           Version: 12.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: sega01 at go-beyond.org

sha256 (and its cousins) have a -c argument to validate against a given
checksum. This works fine on files. Example:

$ echo test > file
$ sha256 file
SHA256 (file) =
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
$ sha256 -c f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
file; echo $?
SHA256 (file) =
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
0
$ sha256 -c dead1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26beef
file; echo $?
SHA256 (file) =
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 [ Failed ]
2

However, stdin appears to either be always positive or false positive:

$ cat file | sha256
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2
$ cat file | sha256 -c
f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2; echo $?
0
$ cat file | sha256 -c
dead1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc2beef; echo $?
0

I think that sha256 -c should give an error or warning with stdin since it is
not handled properly, or preferably function as expected. It would be easy to
be misled by the current behavior.

Please let me know if you need anything else from me. Thank you!

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list