Subject: bin/8238: `gzip -t foo.bz2' prints contents to stdout
To: None <gnats-bugs@gnats.netbsd.org>
From: NAKAJIMA Yoshihiro <nakayosh@kcn.ne.jp>
List: netbsd-bugs
Date: 08/19/1999 08:51:50
>Number:         8238
>Category:       bin
>Synopsis:       `gzip -t foo.bz2' prints contents to stdout
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 19 08:35:02 1999
>Last-Modified:
>Originator:     NAKAJIMA Yoshihiro
>Organization:
>Release:        NetBSD-current 1999/08/18
>Environment:
System: NetBSD asura 1.4K NetBSD 1.4K (ASURA) #0: Thu Aug 19 23:19:42 JST 1999 nakayosh@asura:/usr/src/sys/arch/i386/compile/ASURA i386


>Description:
	In our bunzip2-able gzip, `gzip -t foo.bz2' prints decompressed
	contents to stdout.

>How-To-Repeat:
	% echo HELLO | bzip2 > hello.text.bz2
	% gzip -tv hello.text.bz2
	hello.text.bz2:         HELLO
	 OK
	% 

>Fix:
diff -u2 src/gnu/usr.bin/gzip/unbzip2.c.ORIG src/gnu/usr.bin/gzip/unbzip2.c
--- src/gnu/usr.bin/gzip/unbzip2.c.ORIG	Sun Jul 25 16:06:06 1999
+++ src/gnu/usr.bin/gzip/unbzip2.c	Thu Aug 19 23:56:54 1999
@@ -50,7 +50,9 @@
 
 		if (ret == BZ_STREAM_END) {
-			n = write(out, outbuf, OUTBUFSIZ - bzs.avail_out);
-			if (n < 0)
-				write_error();
+			if (!test) {
+				n = write(out, outbuf, OUTBUFSIZ - bzs.avail_out);
+				if (n < 0)
+					write_error();
+			}
 			break;
 		}
@@ -58,5 +60,6 @@
 			if (end_of_file)
 				read_error();
-			n = write(out, outbuf, OUTBUFSIZ - bzs.avail_out);
+			if (!test)
+				n = write(out, outbuf, OUTBUFSIZ - bzs.avail_out);
 		}
 		else {
>Audit-Trail:
>Unformatted: