Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3]: src/usr.bin/gzip Pull up following revision(s) (requested by ...



details:   https://anonhg.NetBSD.org/src/rev/22594d34ee17
branches:  netbsd-3
changeset: 577571:22594d34ee17
user:      riz <riz%NetBSD.org@localhost>
date:      Sun Nov 27 23:05:41 2005 +0000

description:
Pull up following revision(s) (requested by mrg in ticket #1009):
        usr.bin/gzip/unbzip2.c: revision 1.9
        usr.bin/gzip/gzip.c: revision 1.78
        usr.bin/gzip/zuncompress.c: revision 1.6
apply a patch from onno van der linden in PR#32070 that fixes
these problems:
        1) gzip -vt just prints the contents of a .Z file
        2) gzip -vt will print OK even if the .gz file is corrupt
        3) gzip -vt prints nothing with a .bz2 file
        4) gzip can loop endlessly with a corrupt .bz2 file

diffstat:

 usr.bin/gzip/gzip.c        |  19 +++++++------------
 usr.bin/gzip/unbzip2.c     |   4 ++--
 usr.bin/gzip/zuncompress.c |   4 ++--
 3 files changed, 11 insertions(+), 16 deletions(-)

diffs (103 lines):

diff -r 334339a2f084 -r 22594d34ee17 usr.bin/gzip/gzip.c
--- a/usr.bin/gzip/gzip.c       Sun Nov 27 22:58:41 2005 +0000
+++ b/usr.bin/gzip/gzip.c       Sun Nov 27 23:05:41 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gzip.c,v 1.71.2.2 2005/08/31 10:34:39 tron Exp $       */
+/*     $NetBSD: gzip.c,v 1.71.2.3 2005/11/27 23:05:41 riz Exp $        */
 
 /*
  * Copyright (c) 1997, 1998, 2003, 2004 Matthew R. Green
@@ -32,7 +32,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 2003, 2004 Matthew R. Green\n\
      All rights reserved.\n");
-__RCSID("$NetBSD: gzip.c,v 1.71.2.2 2005/08/31 10:34:39 tron Exp $");
+__RCSID("$NetBSD: gzip.c,v 1.71.2.3 2005/11/27 23:05:41 riz Exp $");
 #endif /* not lint */
 
 /*
@@ -727,10 +727,6 @@
                            BUFLEN - z.avail_in);
 
                        if (in_size == -1) {
-#ifndef SMALL
-                               if (tflag && vflag)
-                                       print_test(filename, 0);
-#endif
                                maybe_warn("failed to read stdin");
                                goto stop_and_fail;
                        } else if (in_size == 0) {
@@ -982,18 +978,13 @@
                }
                continue;
 stop_and_fail:
-               out_tot = 1;
+               out_tot = -1;
 stop:
                break;
        }
        if (state > GZSTATE_INIT)
                inflateEnd(&z);
 
-#ifndef SMALL
-       if (tflag && vflag)
-               print_test(filename, out_tot != -1);
-#endif
-
        free(inbufp);
 out1:
        free(outbufp);
@@ -1595,6 +1586,8 @@
 #ifndef SMALL
         if (vflag && !tflag && usize != -1 && gsize != -1)
                print_verbage(NULL, NULL, usize, gsize);
+       if (vflag && tflag)
+               print_test("(stdin)", usize != -1);
 #endif 
 
 }
@@ -1710,6 +1703,8 @@
        infile = file;
        if (dflag) {
                usize = file_uncompress(file, outfile, sizeof(outfile));
+               if (vflag && tflag)
+                       print_test(file, usize != -1);
                if (usize == -1)
                        return;
                gsize = sbp->st_size;
diff -r 334339a2f084 -r 22594d34ee17 usr.bin/gzip/unbzip2.c
--- a/usr.bin/gzip/unbzip2.c    Sun Nov 27 22:58:41 2005 +0000
+++ b/usr.bin/gzip/unbzip2.c    Sun Nov 27 23:05:41 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: unbzip2.c,v 1.6.2.1 2005/06/15 06:06:01 snj Exp $      */
+/*     $NetBSD: unbzip2.c,v 1.6.2.2 2005/11/27 23:05:41 riz Exp $      */
 
 /* This file is #included by gzip.c */
 
@@ -34,7 +34,7 @@
        if (bytes_in)
                *bytes_in = prelen;
 
-       while (ret != BZ_STREAM_END) {
+       while (ret >= BZ_OK && ret != BZ_STREAM_END) {
                if (bzs.avail_in == 0 && !end_of_file) {
                        n = read(in, inbuf, BUFLEN);
                        if (n < 0)
diff -r 334339a2f084 -r 22594d34ee17 usr.bin/gzip/zuncompress.c
--- a/usr.bin/gzip/zuncompress.c        Sun Nov 27 22:58:41 2005 +0000
+++ b/usr.bin/gzip/zuncompress.c        Sun Nov 27 23:05:41 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zuncompress.c,v 1.5 2004/08/30 14:36:51 dsl Exp $ */
+/*     $NetBSD: zuncompress.c,v 1.5.2.1 2005/11/27 23:05:42 riz Exp $ */
 
 /*-
  * Copyright (c) 1985, 1986, 1992, 1993
@@ -146,7 +146,7 @@
                compressed_pre = NULL;
 
        while ((bin = fread(buf, 1, sizeof(buf), in)) != 0) {
-               if (fwrite(buf, 1, bin, out) != bin) {
+               if (tflag == 0 && fwrite(buf, 1, bin, out) != bin) {
                        free(buf);
                        return -1;
                }



Home | Main Index | Thread Index | Old Index