bin/103845: sha256 /dev/acd0 returns immediately

Bruce Evans bde at zeta.org.au
Sat Sep 30 04:51:51 PDT 2006


On Sat, 30 Sep 2006, Helmut Schellong wrote:

>> Description:
> 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.

Bruce


More information about the freebsd-bugs mailing list