From nobody@FreeBSD.org  Sat Sep 30 06:24:10 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 5E7BA16A407
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Sep 2006 06:24:10 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1B95443D46
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Sep 2006 06:24:10 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k8U6O9PY017193
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 30 Sep 2006 06:24:09 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k8U6O9TM017192;
	Sat, 30 Sep 2006 06:24:09 GMT
	(envelope-from nobody)
Message-Id: <200609300624.k8U6O9TM017192@www.freebsd.org>
Date: Sat, 30 Sep 2006 06:24:09 GMT
From: Helmut Schellong <var@schellong.biz>
To: freebsd-gnats-submit@FreeBSD.org
Subject: sha256 /dev/acd0  returns immediately
X-Send-Pr-Version: www-2.3

>Number:         103845
>Category:       bin
>Synopsis:       sha256(1): sha256 /dev/acd0  returns immediately
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 30 06:30:14 GMT 2006
>Closed-Date:    
>Last-Modified:  Sun Jan 20 04:16:40 UTC 2008
>Originator:     Helmut Schellong
>Release:        6.2 BETA1
>Organization:
>Environment:
See above. (BETA has no X)
>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.
>How-To-Repeat:
command again.
>Fix:
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: Helmut Schellong <var@schellong.biz>
Cc: freebsd-gnats-submit@freebsd.org, freebsd-bugs@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:
 
 >> 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

From: Helmut Schellong <var@schellong.biz>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/103845: sha256 /dev/acd0  returns immediately
Date: Sat, 30 Sep 2006 15:22:50 +0200

 Before sending the bug-report I had read  man sha256.
 The man page tells nothing about act as a filter (isatty(0))
 or special files (stat()).
 I had searched for an option too.
 
 
 -- 
 Mit freundlichen Gren
 Helmut Schellong   var@schellong.biz
 www.schellong.de   www.schellong.com   www.schellong.biz
 http://www.schellong.de/c.htm

From: Bruce Evans <bde@zeta.org.au>
To: Ruslan Ermilov <ru@FreeBSD.org>
Cc: Helmut Schellong <var@schellong.biz>, freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/103845: sha256 /dev/acd0  returns immediately
Date: Sun, 1 Oct 2006 01:30:33 +1000 (EST)

 On Sat, 30 Sep 2006, Ruslan Ermilov wrote:
 
 > On Sat, Sep 30, 2006 at 09:51:45PM +1000, Bruce Evans wrote:
 >>
 >> 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".
 
 I meant "for most types of files, if the files are specified on the
 command line".
 
 > $ md5 /bin/cat /bin/cp
 > MD5 (/bin/cat) = 51c9c34f1d2db0f73d043929556a687b
 > MD5 (/bin/cp) = b456419be246512f9fe3ac1cd4219331
 
 Of course it still works for the usual case :-).
 
 >> 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.
 
 More details:
 - md5 on a symlink follows the symlink so md5 on the symlink itself is
    not supported
 - md5 on a named pipe fails with a seek error
 - md5 on one of the irregular regular files in /proc sees an empty file.
 
 Bruce

From: Bruce Evans <bde@zeta.org.au>
To: Helmut Schellong <var@schellong.biz>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/103845: sha256 /dev/acd0  returns immediately
Date: Sun, 1 Oct 2006 01:36:04 +1000 (EST)

 On Sat, 30 Sep 2006, Helmut Schellong wrote:
 
 > Before sending the bug-report I had read  man sha256.
 > The man page tells nothing about act as a filter (isatty(0))
 > or special files (stat()).
 > I had searched for an option too.
 
 Any program that transforms stdin to stdout is a "filter", but only
 the source code mentions "filter".
 
 Bruce
>Unformatted:
