Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 Sep 2006 21:51:45 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Helmut Schellong <var@schellong.biz>
Cc:        freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org
Subject:   Re: bin/103845: sha256 /dev/acd0  returns immediately
Message-ID:  <20060930205828.M926@epsplex.bde.org>
In-Reply-To: <200609300624.k8U6O9TM017192@www.freebsd.org>
References:  <200609300624.k8U6O9TM017192@www.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060930205828.M926>