From nobody@www.freebsd.org  Mon Jun  3 07:36:18 2002
Return-Path: <nobody@www.freebsd.org>
Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by hub.freebsd.org (Postfix) with ESMTP id 7B54B37B400
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  3 Jun 2002 07:36:18 -0700 (PDT)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g53EaHhG036942
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 3 Jun 2002 07:36:18 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.2/8.12.2/Submit) id g53EaH9I036941;
	Mon, 3 Jun 2002 07:36:17 -0700 (PDT)
Message-Id: <200206031436.g53EaH9I036941@www.freebsd.org>
Date: Mon, 3 Jun 2002 07:36:17 -0700 (PDT)
From: Miguel Angel Vicente Serrano <unixroot@teleline.es>
To: freebsd-gnats-submit@FreeBSD.org
Subject: "file" command hangs when using "-z" option with very little compressed files
X-Send-Pr-Version: www-1.0

>Number:         38857
>Category:       misc
>Synopsis:       "file" command hangs when using "-z" option with very little compressed files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 03 07:40:02 PDT 2002
>Closed-Date:    Sat Oct 19 11:10:35 PDT 2002
>Last-Modified:  Sat Oct 19 11:10:35 PDT 2002
>Originator:     Miguel Angel Vicente Serrano
>Release:        4.5 RELEASE
>Organization:
CIC (Spain)
>Environment:
4.5 RELEASE
>Description:
I compress a very little file using gzip with those commands:
echo aaaa > little ; gzip -9v little
The result is little.gz and when I use the command:
file -z little.gz
the process hangs, using almosr 99% of cpu, as shown on "top" command
>How-To-Repeat:
echo aaaa > little
gzip -9v little
file -z little.gz     ======> process hangs
>Fix:
to fix:

gzcat little.gz | file -
>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@ringlet.net>
To: Miguel Angel Vicente Serrano <unixroot@teleline.es>
Cc: bug-followup@FreeBSD.org
Subject: Re: misc/38857: "file" command hangs when using "-z" option with very little compressed files
Date: Wed, 5 Jun 2002 14:29:30 +0300

 On Mon, Jun 03, 2002 at 07:36:17AM -0700, Miguel Angel Vicente Serrano wrote:
 > 
 > >Number:         38857
 > >Category:       misc
 > >Synopsis:       "file" command hangs when using "-z" option with very little compressed files
 > >Originator:     Miguel Angel Vicente Serrano
 > >Environment:
 > 4.5 RELEASE
 > >Description:
 > I compress a very little file using gzip with those commands:
 > echo aaaa > little ; gzip -9v little
 > The result is little.gz and when I use the command:
 > file -z little.gz
 > the process hangs, using almosr 99% of cpu, as shown on "top" command
 > >How-To-Repeat:
 > echo aaaa > little
 > gzip -9v little
 > file -z little.gz     ======> process hangs
 > >Fix:
 > to fix:
 > 
 > gzcat little.gz | file -
 
 Attached is a patch that fixes this problem; it is made against the
 sources in the FreeBSD 5.0-CURRENT branch, but it applies cleanly
 against both 4.5-RELEASE and 4.6-RC (today's -STABLE).
 
 A note to David O'Brien, the maintainer of FreeBSD's file(1):
 This patch is actually taken from Christos Zoulas's file-3.38; that is,
 it may safely be vendor-imported, and the vendor impotr of the next
 file(1) release will incorporate it with no problems.  I took the time
 to check Christos's new versions right after I had come up with the
 exact same fix for this issue :)
 
 G'luck,
 Peter
 
 -- 
 Peter Pentchev	roam@ringlet.net	roam@FreeBSD.org
 PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
 Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
 This sentence claims to be an Epimenides paradox, but it is lying.
 
 Index: src/contrib/file/compress.c
 ===================================================================
 RCS file: /home/ncvs/src/contrib/file/compress.c,v
 retrieving revision 1.1.1.3
 diff -u -r1.1.1.3 compress.c
 --- src/contrib/file/compress.c	30 Jul 2001 03:09:43 -0000	1.1.1.3
 +++ src/contrib/file/compress.c	5 Jun 2002 11:24:54 -0000
 @@ -120,6 +120,8 @@
  			if (errno == EINTR)
  				continue;
  			return -1;
 +		case 0:
 +			return rn - n;
  		default:
  			n -= rv;
  			buf = ((char *)buf) + rv;
Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: roam 
Responsible-Changed-When: Wed Jun 5 07:51:32 PDT 2002 
Responsible-Changed-Why:  
Over to David O'Brien, the maintainer of file(1) in FreeBSD. 
David, I've included a patch in the audit tail, and it is also 
included verbatin in file-3.38; a vendor import of this patch 
should work just fine. 

I wonder if this could get into 4.6-RELEASE.. Probably not, 
but still.. :) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38857 
State-Changed-From-To: open->closed 
State-Changed-By: obrien 
State-Changed-When: Sat Oct 19 11:10:19 PDT 2002 
State-Changed-Why:  
file(1) has been updated 

http://www.freebsd.org/cgi/query-pr.cgi?pr=38857 
>Unformatted:
