coreutils
coreutils copied to clipboard
cksum: --check can't handle non-UTF-8 in comments
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]