bin/103845: sha256 /dev/acd0 returns immediately

Ruslan Ermilov ru at freebsd.org
Sat Sep 30 05:50:31 PDT 2006


On Sat, Sep 30, 2006 at 09:51:45PM +1000, Bruce Evans wrote:
> 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.
> 
I think you meant to say "for device special files".

$ md5 /bin/cat /bin/cp
MD5 (/bin/cat) = 51c9c34f1d2db0f73d043929556a687b
MD5 (/bin/cp) = b456419be246512f9fe3ac1cd4219331
$ cat /bin/cat | md5
51c9c34f1d2db0f73d043929556a687b
$ cat /bin/cp | md5
b456419be246512f9fe3ac1cd4219331

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


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-bugs/attachments/20060930/1dc849f8/attachment.pgp


More information about the freebsd-bugs mailing list