Subject: sha256sum does not correctly parse file with PGP message header (coreutils 8.26)

From: Toby Kelsey <[email-masked]>
Date: Sun, 26 Mar 2017 11:09:10 +0100

I notice sha256sum does not correctly parse a file with a PGP header. Here is a script log:

toby@toby-pc:/tmp/test$ ls -l
total 57068
-rw-r--r-- 1 toby toby     2046 Mar 26 10:30 hashes.txt
-rw-r--r-- 1 toby toby 58432932 Mar 26 10:30 monero-linux-x64-v0.10.3.0.tar.bz2

toby@toby-pc:/tmp/test$ grep linux-x64 hashes.txt > single.txt

toby@toby-pc:/tmp/test$ cat single.txt
f164112bea75dfd3eaaa905d21129820a996bbe6e5d65cb194609c672a71c3fe  monero-linux-x64-v0.10.3.0.tar.bz2

toby@toby-pc:/tmp/test$ sha256sum -c single.txt
monero-linux-x64-v0.10.3.0.tar.bz2: OK

toby@toby-pc:/tmp/test$ sha256sum -c hashes.txt

sha256sum: ' monero-win-x64-v0.10.3.0.zip': No such file or directory
  monero-win-x64-v0.10.3.0.zip: FAILED open or read
sha256sum: ' monero-win-x86-v0.10.3.0.zip': No such file or directory
  monero-win-x86-v0.10.3.0.zip: FAILED open or read
sha256sum: ' monero-mac-x64-v0.10.3.0.tar.bz2': No such file or directory
  monero-mac-x64-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: ' monero-linux-x64-v0.10.3.0.tar.bz2': No such file or directory
  monero-linux-x64-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: ' monero-linux-x86-v0.10.3.0.tar.bz2': No such file or directory
  monero-linux-x86-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: ' monero-linux-armv7-v0.10.3.0.tar.bz2': No such file or directory
  monero-linux-armv7-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: ' monero-linux-armv8-v0.10.3.0.tar.bz2': No such file or directory
  monero-linux-armv8-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: ' monero-freebsd-x64-v0.10.3.0.tar.bz2': No such file or directory
  monero-freebsd-x64-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: ' monero-dragonflybsd-x64-v0.10.3.0.tar.bz2': No such file or directory
  monero-dragonflybsd-x64-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: ' monero.gui.win.x64.beta.zip': No such file or directory
  monero.gui.win.x64.beta.zip: FAILED open or read
sha256sum: ' monero.gui.mac.x64.beta.tar.bz2': No such file or directory
  monero.gui.mac.x64.beta.tar.bz2: FAILED open or read
sha256sum: ' monero.gui.linux.x64.beta.tar.bz2': No such file or directory
  monero.gui.linux.x64.beta.tar.bz2: FAILED open or read
sha256sum: ' monero.gui.linux.x86.beta.tar.bz2': No such file or directory
  monero.gui.linux.x86.beta.tar.bz2: FAILED open or read
sha256sum: WARNING: 22 lines are improperly formatted
sha256sum: WARNING: 13 listed files could not be read

There is a spurious extra space at the start of filenames in the larger file.
If I just extract the hash lines it works:

toby@toby-pc:/tmp/test$ egrep zip\|bz2 hashes.txt > hashes1.txt

toby@toby-pc:/tmp/test$ sha256sum -c hashes1.txt

sha256sum: monero-win-x64-v0.10.3.0.zip: No such file or directory
monero-win-x64-v0.10.3.0.zip: FAILED open or read
sha256sum: monero-win-x86-v0.10.3.0.zip: No such file or directory
monero-win-x86-v0.10.3.0.zip: FAILED open or read
sha256sum: monero-mac-x64-v0.10.3.0.tar.bz2: No such file or directory
monero-mac-x64-v0.10.3.0.tar.bz2: FAILED open or read
monero-linux-x64-v0.10.3.0.tar.bz2: OK
sha256sum: monero-linux-x86-v0.10.3.0.tar.bz2: No such file or directory
monero-linux-x86-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: monero-linux-armv7-v0.10.3.0.tar.bz2: No such file or directory
monero-linux-armv7-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: monero-linux-armv8-v0.10.3.0.tar.bz2: No such file or directory
monero-linux-armv8-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: monero-freebsd-x64-v0.10.3.0.tar.bz2: No such file or directory
monero-freebsd-x64-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: monero-dragonflybsd-x64-v0.10.3.0.tar.bz2: No such file or directory
monero-dragonflybsd-x64-v0.10.3.0.tar.bz2: FAILED open or read
sha256sum: monero.gui.win.x64.beta.zip: No such file or directory
monero.gui.win.x64.beta.zip: FAILED open or read
sha256sum: monero.gui.mac.x64.beta.tar.bz2: No such file or directory
monero.gui.mac.x64.beta.tar.bz2: FAILED open or read
sha256sum: monero.gui.linux.x64.beta.tar.bz2: No such file or directory
monero.gui.linux.x64.beta.tar.bz2: FAILED open or read
sha256sum: monero.gui.linux.x86.beta.tar.bz2: No such file or directory
monero.gui.linux.x86.beta.tar.bz2: FAILED open or read
sha256sum: WARNING: 12 listed files could not be read

The hash file is from <https://getmonero.org/downloads/hashes.txt>

Regards,
Toby