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

cksum: --check can't handle non-UTF-8 in comments #6573

Open
BenWiederhake opened this issue Jul 15, 2024 · 0 comments
Open

cksum: --check can't handle non-UTF-8 in comments #6573

BenWiederhake opened this issue Jul 15, 2024 · 0 comments

Comments

@BenWiederhake
Copy link
Collaborator

Currently, we convert every line to a String, which has the disadvantage of not properly handling malformed UTF-8, even if it appears in an "irrelevant" place:

$ cat <<EOF | sed -re 's,xxx,\xff,' > sums
SHA256 (README.md) = 4d9b4c7b50b976ec5b0b2dce5a767d2da4b63eb68592017d475c4e11799a333c
# Comment shouldn't matter: >>xxx<<
SHA256 (LICENSE) = 29953405eaa3dcc41c37d1621d55b6a47eee93e05613e439e73295029740b10c
EOF
$ cksum --check sums
README.md: OK
LICENSE: OK
$ cargo run -q cksum --check sums
cksum: stream did not contain valid UTF-8
[$? = 1]

It also isn't supported in other places during check:

$ echo 'U0hBMjU2IChmdW5ref9uYW1lKSA9IDI5OTUzNDA1ZWFhM2RjYzQxYzM3ZDE2MjFkNTViNmE0N2VlZTkzZTA1NjEzZTQzOWU3MzI5NTAyOTc0MGIxMGMK' | base64 -d > sums
$ cksum -c sums 
cksum: 'funky'$'\377''name': No such file or directory
funky�name: FAILED open or read
cksum: WARNING: 1 listed file could not be read
[$? = 1]
$ cargo run -q cksum -c sums 
cksum: stream did not contain valid UTF-8
[$? = 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant