bin/103845: sha256 /dev/acd0 returns immediately
bde at zeta.org.au
Sat Sep 30 05:00:42 PDT 2006
The following reply was made to PR bin/103845; it has been noted by GNATS.
From: Bruce Evans <bde at zeta.org.au>
To: Helmut Schellong <var at schellong.biz>
Cc: freebsd-gnats-submit at freebsd.org, freebsd-bugs at freebsd.org
Subject: Re: bin/103845: sha256 /dev/acd0 returns immediately
Date: Sat, 30 Sep 2006 21:51:45 +1000 (EST)
On Sat, 30 Sep 2006, Helmut Schellong wrote:
> sha256 /dev/acd0 returns *immediately*
> with a wrong checksum.
> CD content is BETA1-disc1.
> dd if=/dev/acd0 of=/usr/z bs=4b; sha256 /usr/z; rm /usr/z
> works fine.
md5(1) and friends haven't worked for files specified on the command
line since 2001. At least for md5, this is due to a bug in libmd.
MDXFileChunk() has been used to implement MDXFile() since 2001, but
MDXFileChunk() cannot be used for this since it assumes that the file
is a regular file (or perhaps a symlink) so that st_size is valid and
the file is seekable.
One workaround is to run md5 on 1 file at a time and not specify the
file on the command line. "md5 </dev/acd0" works because it uses the
"filter" cases which doesn't go near the buggy code.
Another workaround is to use a pipeline: "cat /dev/acd0 | md5". For
pipes, it is essential that md5 act as a filter. However, the previous
workaround is better if you don't start with a pipe.
The workaround can also be used backwards to break the case where the
file or pipe is already open: "md5 /dev/stdin </dev/acd0" gives the
checksum of an empty file.
More information about the freebsd-bugs