Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/gzip do not use directory paths present in gzip file...



details:   https://anonhg.NetBSD.org/src/rev/32f8b44e4964
branches:  trunk
changeset: 335545:32f8b44e4964
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Jan 13 02:37:20 2015 +0000

description:
do not use directory paths present in gzip files with the -N flag,
similar to the problem reported in pigz.

diffstat:

 usr.bin/gzip/gzip.1 |   6 +++---
 usr.bin/gzip/gzip.c |  21 +++++++++++++++------
 2 files changed, 18 insertions(+), 9 deletions(-)

diffs (90 lines):

diff -r a0d0028d208f -r 32f8b44e4964 usr.bin/gzip/gzip.1
--- a/usr.bin/gzip/gzip.1       Tue Jan 13 02:36:22 2015 +0000
+++ b/usr.bin/gzip/gzip.1       Tue Jan 13 02:37:20 2015 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: gzip.1,v 1.23 2014/03/18 18:20:45 riastradh Exp $
+.\"    $NetBSD: gzip.1,v 1.24 2015/01/13 02:37:20 mrg Exp $
 .\"
 .\" Copyright (c) 1997, 2003, 2004 Matthew R. Green
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 18, 2011
+.Dd January 13, 2015
 .Dt GZIP 1
 .Os
 .Sh NAME
@@ -191,7 +191,7 @@
 This manual documents
 .Nx
 .Nm
-version 20040427.
+version 20150113.
 .Sh AUTHORS
 This implementation of
 .Nm
diff -r a0d0028d208f -r 32f8b44e4964 usr.bin/gzip/gzip.c
--- a/usr.bin/gzip/gzip.c       Tue Jan 13 02:36:22 2015 +0000
+++ b/usr.bin/gzip/gzip.c       Tue Jan 13 02:37:20 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gzip.c,v 1.106 2014/10/18 08:33:30 snj Exp $   */
+/*     $NetBSD: gzip.c,v 1.107 2015/01/13 02:37:20 mrg Exp $   */
 
 /*
  * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green
@@ -30,7 +30,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 2003, 2004, 2006\
  Matthew R. Green.  All rights reserved.");
-__RCSID("$NetBSD: gzip.c,v 1.106 2014/10/18 08:33:30 snj Exp $");
+__RCSID("$NetBSD: gzip.c,v 1.107 2015/01/13 02:37:20 mrg Exp $");
 #endif /* not lint */
 
 /*
@@ -160,7 +160,7 @@
 #define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0])
 #define SUFFIX_MAXLEN  30
 
-static const char      gzip_version[] = "NetBSD gzip 20101018";
+static const char      gzip_version[] = "NetBSD gzip 20150113";
 
 static int     cflag;                  /* stdout mode */
 static int     dflag;                  /* decompress mode */
@@ -1311,7 +1311,7 @@
 #ifndef SMALL
        ssize_t rv;
        time_t timestamp = 0;
-       unsigned char name[PATH_MAX + 1];
+       char name[PATH_MAX + 1];
 #endif
 
        /* gather the old name info */
@@ -1372,15 +1372,24 @@
                                goto lose;
                        }
                        if (name[0] != 0) {
+                               char *dp, *nf;
+
+                               /* strip saved directory name */
+                               nf = strrchr(name, '/');
+                               if (nf == NULL)
+                                       nf = name;
+                               else
+                                       nf++;
+
                                /* preserve original directory name */
-                               char *dp = strrchr(file, '/');
+                               dp = strrchr(file, '/');
                                if (dp == NULL)
                                        dp = file;
                                else
                                        dp++;
                                snprintf(outfile, outsize, "%.*s%.*s",
                                                (int) (dp - file), 
-                                               file, (int) rbytes, name);
+                                               file, (int) rbytes, nf);
                        }
                }
        }



Home | Main Index | Thread Index | Old Index