CVS commit: src/usr.bin/compress

2017-07-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jul  4 06:58:55 UTC 2017

Modified Files:
src/usr.bin/compress: compress.1

Log Message:
Add EXIT STATUS section. Use Ex. New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/compress/compress.1

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/compress/compress.1
diff -u src/usr.bin/compress/compress.1:1.15 src/usr.bin/compress/compress.1:1.16
--- src/usr.bin/compress/compress.1:1.15	Mon Jul  3 21:34:18 2017
+++ src/usr.bin/compress/compress.1	Tue Jul  4 06:58:55 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: compress.1,v 1.15 2017/07/03 21:34:18 wiz Exp $
+.\"	$NetBSD: compress.1,v 1.16 2017/07/04 06:58:55 wiz Exp $
 .\"
 .\" Copyright (c) 1986, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -129,8 +129,8 @@ If it is increasing,
 continues to use the existing code dictionary.
 However, if the compression ratio decreases,
 .Nm
-discards the table of substrings and rebuilds it from scratch.  This allows
-the algorithm to adapt to the next "block" of the file.
+discards the table of substrings and rebuilds it from scratch.
+This allows the algorithm to adapt to the next "block" of the file.
 .Pp
 The
 .Fl b
@@ -152,10 +152,8 @@ Compression is generally much better tha
 coding (as used in the historical command pack), or adaptive Huffman
 coding (as used in the historical command compact), and takes less
 time to compute.
-.Pp
-The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
+.Sh EXIT STATUS
+.Ex -std compress
 .Sh SEE ALSO
 .Xr zcat 1
 .Rs



CVS commit: src/usr.bin/compress

2011-08-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 16 03:24:47 UTC 2011

Modified Files:
src/usr.bin/compress: zopen.c

Log Message:
provisional fix for CVE-2011-2895, buffer overflow in decompression


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/compress/zopen.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/compress/zopen.c
diff -u src/usr.bin/compress/zopen.c:1.13 src/usr.bin/compress/zopen.c:1.14
--- src/usr.bin/compress/zopen.c:1.13	Sat Apr 11 08:24:37 2009
+++ src/usr.bin/compress/zopen.c	Mon Aug 15 23:24:47 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: zopen.c,v 1.13 2009/04/11 12:24:37 lukem Exp $	*/
+/*	$NetBSD: zopen.c,v 1.14 2011/08/16 03:24:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 1985, 1986, 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)zopen.c	8.1 (Berkeley) 6/27/93;
 #else
-static char rcsid[] = $NetBSD: zopen.c,v 1.13 2009/04/11 12:24:37 lukem Exp $;
+static char rcsid[] = $NetBSD: zopen.c,v 1.14 2011/08/16 03:24:47 christos Exp $;
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -519,7 +519,7 @@
 		}
 		incode = code;
 
-		/* Special case for KwKwK string. */
+		/* Special case FOR kWkWk string. */
 		if (code = free_ent) {
 			*stackp++ = finchar;
 			code = oldcode;
@@ -527,6 +527,10 @@
 
 		/* Generate output characters in reverse order. */
 		while (code = 256) {
+			if (stackp - de_stack = HSIZE - 1) {
+errno = EOVERFLOW;
+return -1;
+			}
 			*stackp++ = tab_suffixof(code);
 			code = tab_prefixof(code);
 		}



CVS commit: src/usr.bin/compress

2009-04-11 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Apr 11 12:24:37 UTC 2009

Modified Files:
src/usr.bin/compress: compress.c zopen.c

Log Message:
Fix -Wcast-qual and -Wsign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/compress/compress.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/compress/zopen.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/compress/compress.c
diff -u src/usr.bin/compress/compress.c:1.24 src/usr.bin/compress/compress.c:1.25
--- src/usr.bin/compress/compress.c:1.24	Mon Jul 21 14:19:22 2008
+++ src/usr.bin/compress/compress.c	Sat Apr 11 12:24:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: compress.c,v 1.24 2008/07/21 14:19:22 lukem Exp $	*/
+/*	$NetBSD: compress.c,v 1.25 2009/04/11 12:24:37 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)compress.c	8.2 (Berkeley) 1/7/94;
 #else
-__RCSID($NetBSD: compress.c,v 1.24 2008/07/21 14:19:22 lukem Exp $);
+__RCSID($NetBSD: compress.c,v 1.25 2009/04/11 12:24:37 lukem Exp $);
 #endif
 #endif /* not lint */
 
@@ -55,12 +55,12 @@
 #include string.h
 #include unistd.h
 
-void	compress(char *, char *, int);
+void	compress(const char *, const char *, int);
 void	cwarn(const char *, ...) __attribute__((__format__(__printf__,1,2)));
 void	cwarnx(const char *, ...) __attribute__((__format__(__printf__,1,2)));
-void	decompress(char *, char *, int);
-int	permission(char *);
-void	setfile(char *, struct stat *);
+void	decompress(const char *, const char *, int);
+int	permission(const char *);
+void	setfile(const char *, struct stat *);
 void	usage(int);
 
 int	main(int, char *[]);
@@ -199,9 +199,9 @@
 }
 
 void
-compress(char *in, char *out, int bits)
+compress(const char *in, const char *out, int bits)
 {
-	int nr;
+	size_t nr;
 	struct stat isb, sb;
 	const char *error = NULL;
 	FILE *ifp, *ofp;
@@ -298,9 +298,9 @@
 }
 
 void
-decompress(char *in, char *out, int bits)
+decompress(const char *in, const char *out, int bits)
 {
-	int nr;
+	size_t nr;
 	struct stat sb;
 	FILE *ifp, *ofp;
 	int exists, isreg, oreg;
@@ -377,7 +377,7 @@
 }
 
 void
-setfile(char *name, struct stat *fs)
+setfile(const char *name, struct stat *fs)
 {
 	static struct timeval tv[2];
 
@@ -412,7 +412,7 @@
 }
 
 int
-permission(char *fname)
+permission(const char *fname)
 {
 	int ch, first;
 

Index: src/usr.bin/compress/zopen.c
diff -u src/usr.bin/compress/zopen.c:1.12 src/usr.bin/compress/zopen.c:1.13
--- src/usr.bin/compress/zopen.c:1.12	Thu Feb 21 02:50:11 2008
+++ src/usr.bin/compress/zopen.c	Sat Apr 11 12:24:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: zopen.c,v 1.12 2008/02/21 02:50:11 joerg Exp $	*/
+/*	$NetBSD: zopen.c,v 1.13 2009/04/11 12:24:37 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1985, 1986, 1992, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = @(#)zopen.c	8.1 (Berkeley) 6/27/93;
 #else
-static char rcsid[] = $NetBSD: zopen.c,v 1.12 2008/02/21 02:50:11 joerg Exp $;
+static char rcsid[] = $NetBSD: zopen.c,v 1.13 2009/04/11 12:24:37 lukem Exp $;
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -247,7 +247,7 @@
 
 	zs = cookie;
 	count = num;
-	bp = (u_char *)wbp;
+	bp = (const u_char *)wbp;
 	if (state == S_MIDDLE)
 		goto middle;
 	state = S_MIDDLE;
@@ -400,7 +400,7 @@
 			bp = buf;
 			bits = n_bits;
 			bytes_out += bits;
-			if (fwrite(bp, sizeof(char), bits, fp) != bits)
+			if (fwrite(bp, sizeof(char), bits, fp) != (size_t)bits)
 return (-1);
 			bp += bits;
 			bits = 0;
@@ -416,7 +416,7 @@
 			* discover the size increase until after it has read it.
 			*/
 			if (offset  0) {
-if (fwrite(buf, 1, n_bits, fp) != n_bits)
+if (fwrite(buf, 1, n_bits, fp) != (size_t)n_bits)
 	return (-1);
 bytes_out += n_bits;
 			}
@@ -437,7 +437,7 @@
 		/* At EOF, write the rest of the buffer. */
 		if (offset  0) {
 			offset = (offset + 7) / 8;
-			if (fwrite(buf, 1, offset, fp) != offset)
+			if (fwrite(buf, 1, offset, fp) != (size_t)offset)
 return (-1);
 			bytes_out += offset;
 		}