CVS commit: [netbsd-5] src/usr.bin/gzip

2015-03-15 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Mar 15 21:15:01 UTC 2015

Modified Files:
src/usr.bin/gzip [netbsd-5]: Makefile gzip.1 gzip.c zuncompress.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1951):
usr.bin/gzip/Makefile: patch
usr.bin/gzip/gzip.1: revisions 1.20-1.24
usr.bin/gzip/gzip.c: revisions 1.98-1.107
usr.bin/gzip/zuncompress.c: revisions 1.7-1.8
Sync gzip core with HEAD.


To generate a diff of this commit:
cvs rdiff -u -r1.12.4.1 -r1.12.4.2 src/usr.bin/gzip/Makefile
cvs rdiff -u -r1.19 -r1.19.4.1 src/usr.bin/gzip/gzip.1
cvs rdiff -u -r1.93.4.3 -r1.93.4.4 src/usr.bin/gzip/gzip.c
cvs rdiff -u -r1.6.28.1 -r1.6.28.2 src/usr.bin/gzip/zuncompress.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/Makefile
diff -u src/usr.bin/gzip/Makefile:1.12.4.1 src/usr.bin/gzip/Makefile:1.12.4.2
--- src/usr.bin/gzip/Makefile:1.12.4.1	Sun Nov 17 17:59:55 2013
+++ src/usr.bin/gzip/Makefile	Sun Mar 15 21:15:01 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.12.4.1 2013/11/17 17:59:55 bouyer Exp $
+#	$NetBSD: Makefile,v 1.12.4.2 2015/03/15 21:15:01 snj Exp $
 
 USE_FORT?= yes	# data-driven bugs?
 
@@ -32,3 +32,6 @@ LINKS+=		${BINDIR}/gzip ${BINDIR}/gunzip
 .if (defined(HAVE_GCC)  ${HAVE_GCC} == 4) || defined(HAVE_PCC)
 COPTS.gzip.c+=	-Wno-pointer-sign
 .endif
+
+# NetBSD-5 has no -lzma
+CPPFLAGS+=	-DNO_XZ_SUPPORT

Index: src/usr.bin/gzip/gzip.1
diff -u src/usr.bin/gzip/gzip.1:1.19 src/usr.bin/gzip/gzip.1:1.19.4.1
--- src/usr.bin/gzip/gzip.1:1.19	Thu May 29 14:51:27 2008
+++ src/usr.bin/gzip/gzip.1	Sun Mar 15 21:15:01 2015
@@ -1,4 +1,4 @@
-.\	$NetBSD: gzip.1,v 1.19 2008/05/29 14:51:27 mrg Exp $
+.\	$NetBSD: gzip.1,v 1.19.4.1 2015/03/15 21:15:01 snj 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 April 27, 2004
+.Dd January 13, 2015
 .Dt GZIP 1
 .Os
 .Sh NAME
@@ -138,8 +138,8 @@ embedded in the file.
 This option causes the stored filename in the input file to be used
 as the output file.
 .It Fl n , -no-name
-This option stops the filename from being stored in the output
-file.
+This option stops the filename and timestamp from being stored in
+the output file.
 .It Fl q , -quiet
 With this option, no warnings or errors are printed.
 .It Fl r , -recursive
@@ -171,6 +171,7 @@ Options on the command line will overrid
 .Sh SEE ALSO
 .Xr bzip2 1 ,
 .Xr compress 1 ,
+.Xr xz 1 ,
 .Xr fts 3 ,
 .Xr zlib 3
 .Sh HISTORY
@@ -190,9 +191,9 @@ program for
 This manual documents
 .Nx
 .Nm
-version 20040427.
+version 20150113.
 .Sh AUTHORS
 This implementation of
 .Nm
 was written by
-.An Matthew R. Green Aq m...@eterna.com.au .
+.An Matthew R. Green Aq Mt m...@eterna.com.au .

Index: src/usr.bin/gzip/gzip.c
diff -u src/usr.bin/gzip/gzip.c:1.93.4.3 src/usr.bin/gzip/gzip.c:1.93.4.4
--- src/usr.bin/gzip/gzip.c:1.93.4.3	Sun Nov  8 22:55:24 2009
+++ src/usr.bin/gzip/gzip.c	Sun Mar 15 21:15:01 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: gzip.c,v 1.93.4.3 2009/11/08 22:55:24 snj Exp $	*/
+/*	$NetBSD: gzip.c,v 1.93.4.4 2015/03/15 21:15:01 snj 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.93.4.3 2009/11/08 22:55:24 snj Exp $);
+__RCSID($NetBSD: gzip.c,v 1.93.4.4 2015/03/15 21:15:01 snj Exp $);
 #endif /* not lint */
 
 /*
@@ -81,6 +81,9 @@ enum filetype {
 #ifndef NO_PACK_SUPPORT
 	FT_PACK,
 #endif
+#ifndef NO_XZ_SUPPORT
+	FT_XZ,
+#endif
 	FT_LAST,
 	FT_UNKNOWN
 };
@@ -101,6 +104,12 @@ enum filetype {
 #define PACK_MAGIC	\037\036
 #endif
 
+#ifndef NO_XZ_SUPPORT
+#include lzma.h
+#define XZ_SUFFIX	.xz
+#define XZ_MAGIC	\3757zXZ
+#endif
+
 #define GZ_SUFFIX	.gz
 
 #define BUFLEN		(64 * 1024)
@@ -141,6 +150,9 @@ static suffixes_t suffixes[] = {
 #ifndef NO_COMPRESS_SUPPORT
 	SUFFIX(Z_SUFFIX,	),
 #endif
+#ifndef NO_XZ_SUPPORT
+	SUFFIX(XZ_SUFFIX,	),
+#endif
 	SUFFIX(GZ_SUFFIX,	),	/* Overwritten by -S  */
 #endif /* SMALL */
 #undef SUFFIX
@@ -148,7 +160,7 @@ static suffixes_t suffixes[] = {
 #define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0])
 #define SUFFIX_MAXLEN	30
 
-static	const char	gzip_version[] = NetBSD gzip 20091011;
+static	const char	gzip_version[] = NetBSD gzip 20150113;
 
 static	int	cflag;			/* stdout mode */
 static	int	dflag;			/* decompress mode */
@@ -157,6 +169,7 @@ static	int	numflag = 6;		/* gzip -1..-9 
 
 #ifndef SMALL
 static	int	fflag;			/* force mode */
+static	int	kflag;			/* don't delete input files */
 static	int	nflag;			/* don't save name/timestamp */
 static	int	Nflag;			/* don't restore name/timestamp */
 static	int	qflag;			/* quiet mode */
@@ -172,16 +185,17 @@ static	int	

CVS commit: [netbsd-5] src/usr.bin/gzip

2013-12-09 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Dec  9 20:24:18 UTC 2013

Modified Files:
src/usr.bin/gzip [netbsd-5]: zmore

Log Message:
Pullup the following revisions, requested by pettai in ticket #1889:
usr.bin/gzip/zmore: revision 1.5
fix == compatibility problem


To generate a diff of this commit:
cvs rdiff -u -r1.3.34.1 -r1.3.34.2 src/usr.bin/gzip/zmore

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/zmore
diff -u src/usr.bin/gzip/zmore:1.3.34.1 src/usr.bin/gzip/zmore:1.3.34.2
--- src/usr.bin/gzip/zmore:1.3.34.1	Thu Dec  5 18:46:15 2013
+++ src/usr.bin/gzip/zmore	Mon Dec  9 20:24:18 2013
@@ -1,6 +1,6 @@
 #!/bin/sh -
 #
-# $NetBSD: zmore,v 1.3.34.1 2013/12/05 18:46:15 bouyer Exp $
+# $NetBSD: zmore,v 1.3.34.2 2013/12/09 20:24:18 bouyer Exp $
 #
 # $OpenBSD: zmore,v 1.6 2008/08/20 09:22:02 mpf Exp $
 #
@@ -41,7 +41,7 @@ while test $# -ne 0; do
 	esac
 done
 
-if [ `basename $0` == zless ] ; then
+if [ `basename $0` = zless ] ; then
 	pager=${PAGER-less}
 else
 	pager=${PAGER-more}
@@ -49,13 +49,13 @@ fi
 
 # No files means read from stdin
 if [ $# -eq 0 ]; then
-	gzip -cdfq 21 | ${PAGER-more} $flags
+	gzip -cdfq 21 | $pager $flags
 	exit 0
 fi
 
 oterm=`stty -g 2/dev/null`
 while test $# -ne 0; do
-	gzip -cdfq $1 21 | ${PAGER-more} $flags
+	gzip -cdfq $1 21 | $pager $flags
 	prev=$1
 	shift
 	if tty -s  test -n $oterm -a $# -gt 0; then



CVS commit: [netbsd-5] src/usr.bin/gzip

2013-12-05 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Dec  5 18:46:15 UTC 2013

Modified Files:
src/usr.bin/gzip [netbsd-5]: zmore

Log Message:
Pull up following revision(s) (requested by pettai in ticket #1889):
distrib/sets/lists/base/mi: revision 1.1049
distrib/sets/lists/man/mi: revision 1.1449
usr.bin/gzip/Makefile: revision 1.17
usr.bin/gzip/Makefile: revision 1.18
usr.bin/gzip/zmore: revision 1.4
usr.bin/gzip/zmore.1: revision 1.4
Added zless(1) - comes in the lastest version of zmore(1) from OpenBSD
(OKed by tron@)
Add zfgrep that fell off from last update


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.34.1 src/usr.bin/gzip/zmore

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/zmore
diff -u src/usr.bin/gzip/zmore:1.3 src/usr.bin/gzip/zmore:1.3.34.1
--- src/usr.bin/gzip/zmore:1.3	Mon Mar 29 09:59:42 2004
+++ src/usr.bin/gzip/zmore	Thu Dec  5 18:46:15 2013
@@ -1,8 +1,8 @@
 #!/bin/sh -
 #
-# $NetBSD: zmore,v 1.3 2004/03/29 09:59:42 wiz Exp $
+# $NetBSD: zmore,v 1.3.34.1 2013/12/05 18:46:15 bouyer Exp $
 #
-# $OpenBSD: zmore,v 1.4 2003/07/29 07:42:45 otto Exp $
+# $OpenBSD: zmore,v 1.6 2008/08/20 09:22:02 mpf Exp $
 #
 # Copyright (c) 2003 Todd C. Miller todd.mil...@courtesan.com
 #
@@ -41,6 +41,12 @@ while test $# -ne 0; do
 	esac
 done
 
+if [ `basename $0` == zless ] ; then
+	pager=${PAGER-less}
+else
+	pager=${PAGER-more}
+fi
+
 # No files means read from stdin
 if [ $# -eq 0 ]; then
 	gzip -cdfq 21 | ${PAGER-more} $flags



CVS commit: [netbsd-5] src/usr.bin/gzip

2009-12-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Dec  9 04:58:15 UTC 2009

Modified Files:
src/usr.bin/gzip [netbsd-5]: unbzip2.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1182):
usr.bin/gzip/unbzip2.c: revision 1.13
apply a change from Xin LI delp...@delphij.net to avoid problems when
reading from pipes.  introduced with the multi-part bz2 fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.11.6.1 -r1.11.6.2 src/usr.bin/gzip/unbzip2.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/unbzip2.c
diff -u src/usr.bin/gzip/unbzip2.c:1.11.6.1 src/usr.bin/gzip/unbzip2.c:1.11.6.2
--- src/usr.bin/gzip/unbzip2.c:1.11.6.1	Sun Nov  8 22:51:56 2009
+++ src/usr.bin/gzip/unbzip2.c	Wed Dec  9 04:58:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: unbzip2.c,v 1.11.6.1 2009/11/08 22:51:56 snj Exp $	*/
+/*	$NetBSD: unbzip2.c,v 1.11.6.2 2009/12/09 04:58:15 snj Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 static off_t
 unbzip2(int in, int out, char *pre, size_t prelen, off_t *bytes_in)
 {
-	int		ret, end_of_file;
+	int		ret, end_of_file, cold = 0;
 	off_t		bytes_out = 0;
 	bz_stream	bzs;
 	static char	*inbuf, *outbuf;
@@ -84,8 +84,18 @@
 	switch (ret) {
 	case BZ_STREAM_END:
 	case BZ_OK:
-	if (ret == BZ_OK  end_of_file)
-	maybe_err(read);
+	if (ret == BZ_OK  end_of_file) {
+/*
+ * If we hit this after a stream end, consider
+ * it as the end of the whole file and don't
+ * bail out.
+ */
+if (cold == 1)
+	ret = BZ_STREAM_END;
+else
+	maybe_errx(truncated file);
+			}
+			cold = 0;
 	if (!tflag  bzs.avail_out != BUFLEN) {
 ssize_t	n;
 
@@ -98,6 +108,7 @@
 if (BZ2_bzDecompressEnd(bzs) != BZ_OK ||
 BZ2_bzDecompressInit(bzs, 0, 0) != BZ_OK)
 	maybe_errx(bzip2 re-init);
+cold = 1;
 ret = BZ_OK;
 			}
 			break;



CVS commit: [netbsd-5] src/usr.bin/gzip

2009-11-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Nov  8 22:51:56 UTC 2009

Modified Files:
src/usr.bin/gzip [netbsd-5]: unbzip2.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1131):
usr.bin/gzip/unbzip2.c: revision 1.12
fix support for multi-section bzip2 files, as created by pbzip2.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.6.1 src/usr.bin/gzip/unbzip2.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/unbzip2.c
diff -u src/usr.bin/gzip/unbzip2.c:1.11 src/usr.bin/gzip/unbzip2.c:1.11.6.1
--- src/usr.bin/gzip/unbzip2.c:1.11	Mon Apr 28 20:24:13 2008
+++ src/usr.bin/gzip/unbzip2.c	Sun Nov  8 22:51:56 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: unbzip2.c,v 1.11 2008/04/28 20:24:13 martin Exp $	*/
+/*	$NetBSD: unbzip2.c,v 1.11.6.1 2009/11/08 22:51:56 snj Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 	if (bytes_in)
 		*bytes_in = prelen;
 
-	while (ret = BZ_OK  ret != BZ_STREAM_END) {
+	while (ret == BZ_OK) {
 	if (bzs.avail_in == 0  !end_of_file) {
 			ssize_t	n;
 
@@ -86,7 +86,7 @@
 	case BZ_OK:
 	if (ret == BZ_OK  end_of_file)
 	maybe_err(read);
-	if (!tflag) {
+	if (!tflag  bzs.avail_out != BUFLEN) {
 ssize_t	n;
 
 	n = write(out, outbuf, BUFLEN - bzs.avail_out);
@@ -94,7 +94,13 @@
 	maybe_err(write);
 		bytes_out += n;
 	}
-	break;
+			if (ret == BZ_STREAM_END  !end_of_file) {
+if (BZ2_bzDecompressEnd(bzs) != BZ_OK ||
+BZ2_bzDecompressInit(bzs, 0, 0) != BZ_OK)
+	maybe_errx(bzip2 re-init);
+ret = BZ_OK;
+			}
+			break;
 
 	case BZ_DATA_ERROR:
 	maybe_warnx(bzip2 data integrity error);
@@ -107,7 +113,10 @@
 	case BZ_MEM_ERROR:
 	maybe_warnx(bzip2 out of memory);
 			break;
-
+		
+		default:	
+			maybe_warnx(unknown bzip2 error: %d, ret);
+			break;
 	}
 	}
 



CVS commit: [netbsd-5] src/usr.bin/gzip

2009-11-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Nov  8 22:53:21 UTC 2009

Modified Files:
src/usr.bin/gzip [netbsd-5]: gzip.c
Added Files:
src/usr.bin/gzip [netbsd-5]: unpack.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1131):
usr.bin/gzip/unpack.c: revision 1.1
usr.bin/gzip/gzip.c: revision 1.95
add pack uncompression support, from Xin LI delp...@delphij.net


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.93.4.1 src/usr.bin/gzip/gzip.c
cvs rdiff -u -r0 -r1.1.2.2 src/usr.bin/gzip/unpack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/gzip.c
diff -u src/usr.bin/gzip/gzip.c:1.93 src/usr.bin/gzip/gzip.c:1.93.4.1
--- src/usr.bin/gzip/gzip.c:1.93	Sun Aug  3 09:25:05 2008
+++ src/usr.bin/gzip/gzip.c	Sun Nov  8 22:53:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gzip.c,v 1.93 2008/08/03 09:25:05 skrll Exp $	*/
+/*	$NetBSD: gzip.c,v 1.93.4.1 2009/11/08 22:53:21 snj 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.93 2008/08/03 09:25:05 skrll Exp $);
+__RCSID($NetBSD: gzip.c,v 1.93.4.1 2009/11/08 22:53:21 snj Exp $);
 #endif /* not lint */
 
 /*
@@ -78,6 +78,9 @@
 #ifndef NO_COMPRESS_SUPPORT
 	FT_Z,
 #endif
+#ifndef NO_PACK_SUPPORT
+	FT_PACK,
+#endif
 	FT_LAST,
 	FT_UNKNOWN
 };
@@ -94,6 +97,10 @@
 #define Z_MAGIC		\037\235
 #endif
 
+#ifndef NO_PACK_SUPPORT
+#define PACK_MAGIC	\037\036
+#endif
+
 #define GZ_SUFFIX	.gz
 
 #define BUFLEN		(64 * 1024)
@@ -166,7 +173,7 @@
 
 static	void	maybe_err(const char *fmt, ...)
 __attribute__((__format__(__printf__, 1, 2)));
-#ifndef NO_BZIP2_SUPPORT
+#if !defined(NO_BZIP2_SUPPORT) || !defined(NO_PACK_SUPPORT)
 static	void	maybe_errx(const char *fmt, ...)
 __attribute__((__format__(__printf__, 1, 2)));
 #endif
@@ -214,6 +221,10 @@
 static	off_t	zuncompress(FILE *, FILE *, char *, size_t, off_t *);
 #endif
 
+#ifndef NO_PACK_SUPPORT
+static	off_t	unpack(int, int, char *, size_t, off_t *);
+#endif
+
 int main(int, char *p[]);
 
 #ifdef SMALL
@@ -408,7 +419,7 @@
 	exit(2);
 }
 
-#ifndef NO_BZIP2_SUPPORT
+#if !defined(NO_BZIP2_SUPPORT) || !defined(NO_PACK_SUPPORT)
 /* ... without an errno. */
 void
 maybe_errx(const char *fmt, ...)
@@ -1070,6 +1081,11 @@
 		return FT_Z;
 	else
 #endif
+#ifndef NO_PACK_SUPPORT
+	if (memcmp(buf, PACK_MAGIC, 2) == 0)
+		return FT_PACK;
+	else
+#endif
 		return FT_UNKNOWN;
 }
 
@@ -1422,6 +1438,17 @@
 	} else
 #endif
 
+#ifndef NO_PACK_SUPPORT
+	if (method == FT_PACK) {
+		if (lflag) {
+			maybe_warnx(no -l with packed files);
+			goto lose;
+		}
+
+		size = unpack(fd, zfd, NULL, 0, NULL);
+	} else
+#endif
+
 #ifndef SMALL
 	if (method == FT_UNKNOWN) {
 		if (lflag) {
@@ -1615,6 +1642,12 @@
 		fclose(in);
 		break;
 #endif
+#ifndef NO_PACK_SUPPORT
+	case FT_PACK:
+		usize = unpack(STDIN_FILENO, STDOUT_FILENO,
+			   (char *)header1, sizeof header1, gsize);
+		break;
+#endif
 	}
 
 #ifndef SMALL
@@ -1987,6 +2020,9 @@
 #ifndef NO_COMPRESS_SUPPORT
 #include zuncompress.c
 #endif
+#ifndef NO_PACK_SUPPORT
+#include unpack.c
+#endif
 
 static ssize_t
 read_retry(int fd, void *buf, size_t sz)

Added files:

Index: src/usr.bin/gzip/unpack.c
diff -u /dev/null src/usr.bin/gzip/unpack.c:1.1.2.2
--- /dev/null	Sun Nov  8 22:53:21 2009
+++ src/usr.bin/gzip/unpack.c	Sun Nov  8 22:53:21 2009
@@ -0,0 +1,323 @@
+/*	$FreeBSD: head/usr.bin/gzip/unpack.c 194579 2009-06-21 09:39:43Z delphij $	*/
+/*	$NetBSD: unpack.c,v 1.1.2.2 2009/11/08 22:53:21 snj Exp $	*/
+
+/*-
+ * Copyright (c) 2009 Xin LI delp...@freebsd.org
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT 

CVS commit: [netbsd-5] src/usr.bin/gzip

2009-11-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Nov  8 22:54:25 UTC 2009

Modified Files:
src/usr.bin/gzip [netbsd-5]: gzip.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1131):
usr.bin/gzip/gzip.c: revision 1.96
avoid an overflow in suffix handling, from Xin LI delp...@delphij.net.


To generate a diff of this commit:
cvs rdiff -u -r1.93.4.1 -r1.93.4.2 src/usr.bin/gzip/gzip.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/gzip.c
diff -u src/usr.bin/gzip/gzip.c:1.93.4.1 src/usr.bin/gzip/gzip.c:1.93.4.2
--- src/usr.bin/gzip/gzip.c:1.93.4.1	Sun Nov  8 22:53:21 2009
+++ src/usr.bin/gzip/gzip.c	Sun Nov  8 22:54:25 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gzip.c,v 1.93.4.1 2009/11/08 22:53:21 snj Exp $	*/
+/*	$NetBSD: gzip.c,v 1.93.4.2 2009/11/08 22:54:25 snj 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.93.4.1 2009/11/08 22:53:21 snj Exp $);
+__RCSID($NetBSD: gzip.c,v 1.93.4.2 2009/11/08 22:54:25 snj Exp $);
 #endif /* not lint */
 
 /*
@@ -146,6 +146,7 @@
 #undef SUFFIX
 };
 #define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0])
+#define SUFFIX_MAXLEN	30
 
 static	const char	gzip_version[] = NetBSD gzip 20060927;
 
@@ -334,6 +335,8 @@
 		case 'S':
 			len = strlen(optarg);
 			if (len != 0) {
+if (len  SUFFIX_MAXLEN)
+	errx(1, incorrect suffix: '%s', optarg);
 suffixes[0].zipped = optarg;
 suffixes[0].ziplen = len;
 			} else {
@@ -1200,7 +1203,7 @@
 		/* Add (usually) .gz to filename */
 		if ((size_t)snprintf(outfile, outsize, %s%s,
 	file, suffixes[0].zipped) = outsize)
-			memcpy(outfile - suffixes[0].ziplen - 1,
+			memcpy(outfile + outsize - suffixes[0].ziplen - 1,
 suffixes[0].zipped, suffixes[0].ziplen + 1);
 
 #ifndef SMALL



CVS commit: [netbsd-5] src/usr.bin/gzip

2009-11-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Sun Nov  8 22:55:25 UTC 2009

Modified Files:
src/usr.bin/gzip [netbsd-5]: gzip.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1131):
usr.bin/gzip/gzip.c: revision 1.97
update version to today.


To generate a diff of this commit:
cvs rdiff -u -r1.93.4.2 -r1.93.4.3 src/usr.bin/gzip/gzip.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/gzip.c
diff -u src/usr.bin/gzip/gzip.c:1.93.4.2 src/usr.bin/gzip/gzip.c:1.93.4.3
--- src/usr.bin/gzip/gzip.c:1.93.4.2	Sun Nov  8 22:54:25 2009
+++ src/usr.bin/gzip/gzip.c	Sun Nov  8 22:55:24 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gzip.c,v 1.93.4.2 2009/11/08 22:54:25 snj Exp $	*/
+/*	$NetBSD: gzip.c,v 1.93.4.3 2009/11/08 22:55:24 snj 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.93.4.2 2009/11/08 22:54:25 snj Exp $);
+__RCSID($NetBSD: gzip.c,v 1.93.4.3 2009/11/08 22:55:24 snj Exp $);
 #endif /* not lint */
 
 /*
@@ -148,7 +148,7 @@
 #define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0])
 #define SUFFIX_MAXLEN	30
 
-static	const char	gzip_version[] = NetBSD gzip 20060927;
+static	const char	gzip_version[] = NetBSD gzip 20091011;
 
 static	int	cflag;			/* stdout mode */
 static	int	dflag;			/* decompress mode */