Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sha256sum reports false mismatch if input not delimited by two spaces #246

Open
rittneje opened this issue Apr 7, 2022 · 1 comment
Open

Comments

@rittneje
Copy link

rittneje commented Apr 7, 2022

$ docker pull alpine:3.15
$ docker run --rm -it alpine:3.15
# touch empty
# echo 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 empty' | sha256sum -c
sha256sum: WARNING: 1 of 1 computed checksums did NOT match
# echo 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  empty' | sha256sum -c
empty: OK

For some reason, the Alpine version of sha256sum requires two spaces between the hash and file path. No other version of sha256sum has this requirement. For instance:

$ docker pull ubuntu:focal
$ docker run --rm -it ubuntu:focal
# touch empty
# echo 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 empty' | sha256sum -c
empty: OK
# echo 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  empty' | sha256sum -c
empty: OK

This was reported in gliderlabs/docker-alpine#174 but was never fixed.

At minimum, sha256sum should output a proper error message. It does at least complain if you pass -w, but this flag should not be required, and the error message is too vague anyway.

# echo 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 empty' | sha256sum -wc
sha256sum: invalid format
sha256sum: WARNING: 1 of 1 computed checksums did NOT match

Even though Alpine may be technically correct in failing, it is definitely a poor experience for newcomers, especially because other versions of sha256sum are more forgiving. This only discourages people from using sha256sum (because it's "broken"), or from using Alpine entirely.

@ncopa
Copy link
Contributor

ncopa commented Apr 8, 2022

This is a busybox bug/feature. I agree that it is annoying and would be nice to fix.
Could you please report it here: https://bugs.busybox.net/

I can try give it a shot when I get some time for it. I guess it shouldn't be too hard to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants