Subject: bin/25189: zcat (gzip -cd) fails with multiple files.
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <tshiozak@netbsd.org>
List: netbsd-bugs
Date: 04/15/2004 10:43:19
>Number:         25189
>Category:       bin
>Synopsis:       zcat (gzip -cd) fails with multiple files.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 15 10:44:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Takuya SHIOZAKI
>Release:        current
>Organization:
---
>Environment:
NetBSD aoi.prod.astec.co.jp 2.0B NetBSD 2.0B (AOI) #4: Tue Apr  6 18:09:28 JST 2004  tshiozak@aoi.prod.astec.co.jp:/usr/home/current-build/src/sys/arch/i386/compile/AOI i386
>Description:
gzip -cd and zcat fails to uncompress multiple files.


>How-To-Repeat:
% zcat a.gz b.gz > /dev/null
zcat: failed fwrite: Bad file descriptor

>Fix:
file_uncompress() in gzip.c:

   845                  if (cflag == 0) {
...snip...
   855                  } else
   856                          out = stdout;
   857  
   858                  if ((size = gz_uncompress(in, out)) == 0) {
   859                          unlink(outfile);
   860                          goto lose;
   861                  }
   862                  if (fclose(out))
   863                          maybe_err(1, "failed fclose");

this fclose() is unnecessary if cflags != 0.

>Release-Note:
>Audit-Trail:
>Unformatted: