Subject: bin/25192: zcat (gzip -cd) assume stdin is compressed with gzip(1).
To: None <gnats-bugs@gnats.NetBSD.org>
From: Takahiro Kambe <taca@back-street.net>
List: netbsd-bugs
Date: 04/15/2004 22:49:22
>Number:         25192
>Category:       bin
>Synopsis:       zcat (gzip -cd) assume stdin is compressed with gzip(1).
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 15 13:50:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Takahiro Kambe
>Release:        NetBSD 2.0C
>Organization:
Takahiro Kambe
>Environment:
	
	
System: NetBSD edge.back-street.net 2.0C NetBSD 2.0C (CF-R1) #108: Wed Apr 14 00:39:58 JST 2004 taca@edge.back-street.net:/var/obj/sys/arch/i386/compile/CF-R1 i386
Architecture: i386
Machine: i386
>Description:
	zcat (gzip cd) assume stdin is compressed with gzip(1).
	If a file is supplied as argument, it checks compression scheme.
>How-To-Repeat:

% ls -l data 
-rw-r--r--  1 taca  wheel  77 Apr 15 22:36 data
% gzip < data > data.gz
% bzip2 < data > data.bz2
% compress < data > data.Z  
% gzip -dc < data.gz > data.gz.out
% gzip -dc < data.bz2 > data.bz2.out
% gzip -dc < data.Z > data.Z.out  
% ls -l data.*
-rw-r--r--  1 taca  wheel   82 Apr 15 22:42 data.Z
-rw-r--r--  1 taca  wheel   82 Apr 15 22:42 data.Z.out
-rw-r--r--  1 taca  wheel  115 Apr 15 22:42 data.bz2
-rw-r--r--  1 taca  wheel  115 Apr 15 22:42 data.bz2.out
-rw-r--r--  1 taca  wheel   94 Apr 15 22:42 data.gz
-rw-r--r--  1 taca  wheel   77 Apr 15 22:42 data.gz.out

	Only data.gz is uncompressed with "gzip -dc < ".

>Fix:
	Check compressed data's type in handle_stdin().
>Release-Note:
>Audit-Trail:
>Unformatted: