OpenBSD CVS

CVS log for src/usr.bin/compress/main.c


[BACK] Up to [local] / src / usr.bin / compress

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.106 / (download) - annotate - [select for diffs], Sat Nov 11 02:52:55 2023 UTC (6 months, 1 week ago) by gkoehler
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.105: +3 -3 lines
Diff to previous 1.105 (colored)

Ignore -N in "gzip -dN <in.gz" and "zcat -N in.gz"

Have -c override -N, like other gzip implementations.  Before, our -N
(decompress to stored name) overrode -c (cat to stdout) and crashed
with a pledge violation, because the pledge for -c excludes wpath.

Guilherme Janczak reported the pledge violation in July 2022 and
provided a diff to prevent it, along with a regress test.  I rewrote
the diff and expanded the regress.

ok kn@ millert@

Revision 1.105 / (download) - annotate - [select for diffs], Fri Aug 11 04:45:05 2023 UTC (9 months, 1 week ago) by guenther
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4
Changes since 1.104: +3 -5 lines
Diff to previous 1.104 (colored)

Replace use of the old BSD st_*timespec members in struct stat with
the POSIX-standard st_*tim members.

ok millert@

Revision 1.104 / (download) - annotate - [select for diffs], Wed Oct 26 00:40:40 2022 UTC (18 months, 3 weeks ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.103: +81 -76 lines
Diff to previous 1.103 (colored)

compress: fix minor TOCTOU when checking for existing file
Use open(2) + fstat(2) instead of stat(2) + open(2).  The file open
code has been moved into its own functions so it can be shared
between docompress() and dodecompress().

Revision 1.103 / (download) - annotate - [select for diffs], Sun Oct 23 19:06:35 2022 UTC (18 months, 3 weeks ago) by millert
Branch: MAIN
Changes since 1.102: +25 -33 lines
Diff to previous 1.102 (colored)

The cat_opts and decomp_opts fields in struct compressor are unused
so just remove them.  Also mark functions private to main.c as
static.  For SMALL, longopts can be NULL instead of an empty array.
OK kn@

Revision 1.102 / (download) - annotate - [select for diffs], Sat Oct 22 14:41:27 2022 UTC (18 months, 3 weeks ago) by millert
Branch: MAIN
Changes since 1.101: +45 -16 lines
Diff to previous 1.101 (colored)

Add support to gunzip for zip files that contain a single member.
This matches the behavior of GNU gzip and is most useful with "gunzip
-c" to pipe the uncompressed output.  It will not decompress a file
with more than one member unless in cat mode, in which case only
the first file is displayed.

To decompress a .zip file without the -c option, "-S .zip" must be
specified. The file name stored in the .zip file is not used unless
the -N option is specified. This is consistent with GNU gzip).

Does not increase the size of gzip on the install media.
OK jmc@ for documentation.

Revision 1.101 / (download) - annotate - [select for diffs], Mon Aug 29 19:42:01 2022 UTC (20 months, 2 weeks ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.100: +3 -2 lines
Diff to previous 1.100 (colored)

Fix growth check in compress(1)/gzip(1)

If a compressed file is larger than its expanded version, compress(1) and
gzip(1) don't compress unless -f is given. As found by gkoehler, the check
is not quite correct for very small files or files with sufficiently random
data. Fix the check so that slight growth still triggers the check.

ok millert

Revision 1.100 / (download) - annotate - [select for diffs], Sun Apr 10 18:05:39 2022 UTC (2 years, 1 month ago) by jca
Branch: MAIN
Changes since 1.99: +7 -5 lines
Diff to previous 1.99 (colored)

Print a more accurate message when -v is used with -k

Report and different proposal by "prx", ok millert@

Revision 1.99 / (download) - annotate - [select for diffs], Mon Mar 14 21:52:08 2022 UTC (2 years, 2 months ago) by solene
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.98: +13 -9 lines
Diff to previous 1.98 (colored)

add -k flag to gzip and gunzip

When using this flag, the input file is kept after
compression or decompression, this makes our gzip
more compatible with the other gzip

changes reworked by jca@, thanks
ok jca@ millert@

Revision 1.98 / (download) - annotate - [select for diffs], Mon Jan 18 00:46:58 2021 UTC (3 years, 4 months ago) by mortimer
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.97: +3 -1 lines
Diff to previous 1.97 (colored)

Move definition of pmode to main.c instead of a compress.h. Avoids linker
issues with -fno-common.

ok deraadt@

Revision 1.97 / (download) - annotate - [select for diffs], Mon Oct 12 13:56:22 2020 UTC (3 years, 7 months ago) by naddy
Branch: MAIN
Changes since 1.96: +4 -2 lines
Diff to previous 1.96 (colored)

Accommodate POSIX basename(3) that takes a non-const parameter and
may modify the string buffer.  ok millert@

Revision 1.96 / (download) - annotate - [select for diffs], Fri Jun 28 13:35:00 2019 UTC (4 years, 10 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.95: +5 -5 lines
Diff to previous 1.95 (colored)

When system calls indicate an error they return -1, not some arbitrary
value < 0.  errno is only updated in this case.  Change all (most?)
callers of syscalls to follow this better, and let's see if this strictness
helps us in the future.

Revision 1.95 / (download) - annotate - [select for diffs], Mon May 27 15:11:01 2019 UTC (4 years, 11 months ago) by millert
Branch: MAIN
Changes since 1.94: +5 -4 lines
Diff to previous 1.94 (colored)

For "gunzip -N", only use the basename of the stored path.
Fixes a directory traversal bug when the stored name includes a
directory component.  Both GNU gzip and our gzip store the basename
of the path when compressing but a malicious .gz file could contain
an arbitrary path.  Problem found by elvis alien.  OK deraadt@

Revision 1.94 / (download) - annotate - [select for diffs], Sat Sep 3 13:26:50 2016 UTC (7 years, 8 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.93: +6 -6 lines
Diff to previous 1.93 (colored)

remove parens from method calls

Revision 1.93 / (download) - annotate - [select for diffs], Sat Sep 3 12:29:30 2016 UTC (7 years, 8 months ago) by tedu
Branch: MAIN
Changes since 1.92: +9 -5 lines
Diff to previous 1.92 (colored)

the SMALL code made a half hearted effort to exclude compression code
but some of the write code remained. shuffle things around a bit to make
the exclusion more complete.

Revision 1.92 / (download) - annotate - [select for diffs], Sat Sep 3 11:41:10 2016 UTC (7 years, 8 months ago) by tedu
Branch: MAIN
Changes since 1.91: +20 -23 lines
Diff to previous 1.91 (colored)

start pulling apart some function pointers that take too many parameters
because of excessive code sharing. compression and decompression are not
entirely similar, they should share less.
ok joerg millert

Revision 1.91 / (download) - annotate - [select for diffs], Thu Jul 14 08:31:18 2016 UTC (7 years, 10 months ago) by semarie
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.90: +2 -2 lines
Diff to previous 1.90 (colored)

make several program to use "chown" promise.

it allows chown(2) call to change the user or group on a file.

- usr.bin/compress : aka gzip
- usr.bin/mg : open a file for writing
- usr.bin/sed : inplace editing
- usr.bin/sort : if outfile equals one of the input files

ok deraadt@ tb@

(and a reminder from Remi Locherer)

warning: in order to use it, you must have a recent kernel with the new
promise.

Revision 1.90 / (download) - annotate - [select for diffs], Sat Oct 17 21:34:07 2015 UTC (8 years, 7 months ago) by naddy
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.89: +5 -1 lines
Diff to previous 1.89 (colored)

Tighten pledge: We only write to stdio and never to any files if
in cat mode (-c, zcat), or in test mode (-t), or if there are no
file arguments and there is no -o outfile.  Due to fts(3) we require
rpath even for compress <in >out.

"seems sound" deraadt@

Revision 1.89 / (download) - annotate - [select for diffs], Fri Oct 9 01:37:07 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.88: +3 -3 lines
Diff to previous 1.88 (colored)

Change all tame callers to namechange to pledge(2).

Revision 1.88 / (download) - annotate - [select for diffs], Sun Oct 4 16:50:29 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.87: +2 -2 lines
Diff to previous 1.87 (colored)

Also needs "rpath" for some circumstances.

Revision 1.87 / (download) - annotate - [select for diffs], Sat Oct 3 04:19:14 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.86: +4 -1 lines
Diff to previous 1.86 (colored)

gzip can use tame "stdio wpath cpath fattr".  this blocks a lot of
system behaviours such as forking, execve, sockets, etc.

in theory this extended by parsing the arguments first, and creating
the whitepathlist. the pathlist probably needs to be directory-oriented,
rather than exact path of files, because a gzip file may specify the
filename it wants (and that won't be available until it is opened, and
partially parsed).  anyone want to give this a try?

gzip was an early goal for capsicum.  who is running a capsicum gzip?

Revision 1.86 / (download) - annotate - [select for diffs], Sun Aug 30 21:06:24 2015 UTC (8 years, 8 months ago) by deraadt
Branch: MAIN
Changes since 1.85: +4 -5 lines
Diff to previous 1.85 (colored)

Ignore setuid/setgid settings from a compress/gzip file; original CSRG
code.  Found by trondd exercising coverage of tame in gzip.
ok guenther millert kettenis

Revision 1.85 / (download) - annotate - [select for diffs], Thu Jun 25 02:04:08 2015 UTC (8 years, 10 months ago) by uebayasi
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.84: +2 -2 lines
Diff to previous 1.84 (colored)

Put fts_close() where missing.

Not bugs in short-lived commands that call exit() -> _exit() immediately,
but for idempotency.

Originally found in ls(1) by Valgrind.  Changes for other commands are
from deraadt@.  Reviewed by me, tested in snapshots.

OK deraadt@

Revision 1.84 / (download) - annotate - [select for diffs], Sun May 3 19:44:59 2015 UTC (9 years ago) by guenther
Branch: MAIN
Changes since 1.83: +6 -6 lines
Diff to previous 1.83 (colored)

Preserve times to nanosecond precision instead of just microsecond.
Prefer to set attributes by fd for regular files, and not follwing
symlinks for others.

ok brynet@ millert@

Revision 1.83 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:06 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.82: +6 -6 lines
Diff to previous 1.82 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.82 / (download) - annotate - [select for diffs], Wed Oct 8 03:59:11 2014 UTC (9 years, 7 months ago) by doug
Branch: MAIN
Changes since 1.81: +3 -3 lines
Diff to previous 1.81 (colored)

userland reallocarray audit.

Replace malloc() and realloc() calls that may have integer overflow in the
multiplication of the arguments with reallocarray().

ok deraadt@

Revision 1.81 / (download) - annotate - [select for diffs], Mon Jan 27 17:13:10 2014 UTC (10 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.80: +61 -22 lines
Diff to previous 1.80 (colored)

Remove the no-op flags -L and -V from compress(1), these options
come from GNU zip and they were never in compress(1) until we added
gzip(1) support to it.  Also remove -g flag from gzip(1) as it is
non-standard and only makes sense in compress(1).
Joint work with jmc@ and sobrado@.  OK jmc@, sobrado@

Revision 1.80 / (download) - annotate - [select for diffs], Wed Apr 17 17:43:55 2013 UTC (11 years, 1 month ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.79: +4 -2 lines
Diff to previous 1.79 (colored)

zlib info header is 32-bit; handle for localtime() call; ok millert

Revision 1.79 / (download) - annotate - [select for diffs], Sun Sep 30 14:50:38 2012 UTC (11 years, 7 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.78: +2 -2 lines
Diff to previous 1.78 (colored)

When outputting to stdout and compressing would grow the file, exit
normally instead of with a value of 2.  Also avoids unlinking the
file "stdout" in the current directory in this case.
OK miod@ sthen@ henning@ beck@

Revision 1.78 / (download) - annotate - [select for diffs], Thu Sep 22 10:41:04 2011 UTC (12 years, 7 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.77: +31 -48 lines
Diff to previous 1.77 (colored)

Remove the rcsid which were intentionally skipped in the "purge of 2009"
because the -V command printed them... gut the -V (and -L, while there)
to be silent.
ok miod jsg

Revision 1.77 / (download) - annotate - [select for diffs], Sat Mar 5 20:12:42 2011 UTC (13 years, 2 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.76: +29 -21 lines
Diff to previous 1.76 (colored)

Fix potential crash when GZIP variable set and more than 512 command
line args specified.  Closes PR 6573.  OK deraadt@

Revision 1.76 / (download) - annotate - [select for diffs], Wed Jul 28 23:52:01 2010 UTC (13 years, 9 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.75: +3 -3 lines
Diff to previous 1.75 (colored)

Truncate output file when compressing.  OK deraadt@

Revision 1.75 / (download) - annotate - [select for diffs], Sat Apr 18 18:21:54 2009 UTC (15 years, 1 month ago) by naddy
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.74: +5 -5 lines
Diff to previous 1.74 (colored)

allow -V (show version) in decompression mode; ok millert@

Revision 1.74 / (download) - annotate - [select for diffs], Wed Oct 8 17:06:30 2008 UTC (15 years, 7 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.73: +8 -3 lines
Diff to previous 1.73 (colored)

For "gunzip -N", the name stored in the gzip header has no directory,
so write the uncompressed file in the same directory we would use
were the -N option not specified.  Closes PR 5224

Revision 1.73 / (download) - annotate - [select for diffs], Sun Jul 27 13:15:31 2008 UTC (15 years, 9 months ago) by sobrado
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.72: +13 -12 lines
Diff to previous 1.72 (colored)

an enum specifier is more elegant than a set of #defines;
storing the program mode variable (pmode) as a global let us have
a more consistent prototype for usage().

changes suggested by pyr@.

ok pyr@

Revision 1.72 / (download) - annotate - [select for diffs], Sat Jul 5 21:00:38 2008 UTC (15 years, 10 months ago) by sobrado
Branch: MAIN
Changes since 1.71: +31 -14 lines
Diff to previous 1.71 (colored)

each utility must have its own usage and an unique set of options.

diff written by millert based on a previous one by me;
millert's diff has a much better style and adds support for different
sets of options for each utility.

ok millert@

Revision 1.71 / (download) - annotate - [select for diffs], Mon Feb 25 16:53:55 2008 UTC (16 years, 2 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.70: +3 -3 lines
Diff to previous 1.70 (colored)

For the -l flag, set testmode to 1 instead of incrementing it.  Fixes
a bogus error message problem when the -t and -l flags are used together.
OK miod@

Revision 1.70 / (download) - annotate - [select for diffs], Wed Apr 4 13:29:45 2007 UTC (17 years, 1 month ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.69: +17 -14 lines
Diff to previous 1.69 (colored)

Rename "nosave" variable to "storename" in hopes of clarifying
the code a bit.  OK otto@

Revision 1.69 / (download) - annotate - [select for diffs], Tue Apr 3 20:25:35 2007 UTC (17 years, 1 month ago) by millert
Branch: MAIN
Changes since 1.68: +6 -8 lines
Diff to previous 1.68 (colored)

Fix PR 5417; gunzip should set the timestamp based on the
compressed file by default.  OK otto@

Revision 1.68 / (download) - annotate - [select for diffs], Thu Jan 18 20:53:36 2007 UTC (17 years, 4 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.67: +3 -3 lines
Diff to previous 1.67 (colored)

We don't want to use GZIP for compress.  Only examine GZIP environment
variable when invoked as gzip, gunzip, gzcat, etc.  OK otto@

Revision 1.67 / (download) - annotate - [select for diffs], Fri Dec 1 08:14:53 2006 UTC (17 years, 5 months ago) by otto
Branch: MAIN
Changes since 1.66: +50 -45 lines
Diff to previous 1.66 (colored)

Fix two bugs: stdin is processed and the current working dir is not
readable and having a file named '-'. PR 5301 and 5302. Diff from Vadim
Vygonets, with some changes from me. ok millert@

Revision 1.66 / (download) - annotate - [select for diffs], Mon Mar 13 14:49:59 2006 UTC (18 years, 2 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.65: +100 -73 lines
Diff to previous 1.65 (colored)

Remove dependence on /dev/stdin and /dev/stdout
Deal correctly with compressing both stdin and regular files
OK jaredy@ deraadt@

Revision 1.65 / (download) - annotate - [select for diffs], Fri Jul 22 08:38:46 2005 UTC (18 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.64: +4 -3 lines
Diff to previous 1.64 (colored)

sort synopsis and options list; sync usage() (as best we can);
help + ok jaredy@

Revision 1.64 / (download) - annotate - [select for diffs], Mon Jul 11 14:16:47 2005 UTC (18 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.63: +10 -10 lines
Diff to previous 1.63 (colored)

Don't set timestamps created from stack garbage when compressing
from stdin.  Based on a patch from marc@

Revision 1.63 / (download) - annotate - [select for diffs], Sun Jun 26 18:20:26 2005 UTC (18 years, 10 months ago) by otto
Branch: MAIN
Changes since 1.62: +9 -15 lines
Diff to previous 1.62 (colored)

be a bit more carefull not writing to the stream after the timestamps
have been set. ok deraadt@

Revision 1.62 / (download) - annotate - [select for diffs], Sun Apr 17 16:17:39 2005 UTC (19 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.61: +4 -5 lines
Diff to previous 1.61 (colored)

spacing

Revision 1.61 / (download) - annotate - [select for diffs], Sun Apr 17 16:07:16 2005 UTC (19 years, 1 month ago) by hshoexer
Branch: MAIN
Changes since 1.60: +6 -6 lines
Diff to previous 1.60 (colored)

use correct functions names in warn()

ok deraadt millert

Revision 1.60 / (download) - annotate - [select for diffs], Thu Apr 14 18:28:27 2005 UTC (19 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.59: +19 -11 lines
Diff to previous 1.59 (colored)

use f{chown,chmod,utimes,chflags} instead; done with hshoexer, ok otto mickey

Revision 1.59 / (download) - annotate - [select for diffs], Thu Feb 24 09:44:36 2005 UTC (19 years, 2 months ago) by moritz
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.58: +7 -2 lines
Diff to previous 1.58 (colored)

remove docompress() completely in case of -DSMALL and
replace it with a better error message.

ok millert@ henning@

Revision 1.58 / (download) - annotate - [select for diffs], Mon Feb 7 08:37:28 2005 UTC (19 years, 3 months ago) by otto
Branch: MAIN
Changes since 1.57: +3 -3 lines
Diff to previous 1.57 (colored)

In list mode (which implies test mode), do not forget to initialize
uncompressed_name. Spotted by markus@; ok hshoexer@ millert@

Revision 1.57 / (download) - annotate - [select for diffs], Thu Jan 27 12:58:22 2005 UTC (19 years, 3 months ago) by otto
Branch: MAIN
Changes since 1.56: +3 -3 lines
Diff to previous 1.56 (colored)

Compute compression ratio using signed arithmetic, since the compressed size
might be larger than the original, yielding negative percentages. Spotted by
markus@

ok henning@ hshoexer@

Revision 1.56 / (download) - annotate - [select for diffs], Mon Sep 20 18:53:20 2004 UTC (19 years, 8 months ago) by millert
Branch: MAIN
Changes since 1.55: +4 -3 lines
Diff to previous 1.55 (colored)

Make "gunzip foo.bar" work when there is a foo.bar.gz file.
OK otto@

Revision 1.55 / (download) - annotate - [select for diffs], Thu Jul 29 04:07:44 2004 UTC (19 years, 9 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.54: +11 -12 lines
Diff to previous 1.54 (colored)

Don't set the output filename when in -t mode.  Avoids an error when
the input filename lacks a .gz.  OK mickey@

Revision 1.54 / (download) - annotate - [select for diffs], Sun Feb 29 13:59:15 2004 UTC (20 years, 2 months ago) by markus
Branch: MAIN
CVS Tags: OPENBSD_3_5_BASE, OPENBSD_3_5
Changes since 1.53: +5 -3 lines
Diff to previous 1.53 (colored)

don't stat(2) outfile in testmode; ok millert@, miod@

Revision 1.47.2.1 / (download) - annotate - [select for diffs], Sat Jan 31 04:17:53 2004 UTC (20 years, 3 months ago) by brad
Branch: OPENBSD_3_4
Changes since 1.47: +6 -3 lines
Diff to previous 1.47 (colored) next main 1.48 (colored)

MFC:
Fix by millert@

Make exit code for "unknown suffix" and "name too long" match GNU gzip.
Fixes an interaction with the perl CPAN module which checks the exit value.

ok deraadt@ millert@

Revision 1.53 / (download) - annotate - [select for diffs], Thu Jan 22 18:50:39 2004 UTC (20 years, 4 months ago) by millert
Branch: MAIN
Changes since 1.52: +6 -3 lines
Diff to previous 1.52 (colored)

Make exit code for "unknown suffix" and "name too long" match GNU gzip.
Fixes an interaction with the perl CPAN module which checks the exit value.

Revision 1.52 / (download) - annotate - [select for diffs], Tue Dec 16 23:32:24 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.51: +5 -3 lines
Diff to previous 1.51 (colored)

do not implement -L (print copyright) with SMALL
186 bytes more bytes we can waste elsewhere

Revision 1.51 / (download) - annotate - [select for diffs], Tue Dec 16 23:23:50 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.50: +3 -3 lines
Diff to previous 1.50 (colored)

really don't do -V #ifdef SMALL

Revision 1.50 / (download) - annotate - [select for diffs], Tue Dec 16 22:46:26 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.49: +3 -7 lines
Diff to previous 1.49 (colored)

do not include rcsids with -DSMALL and as it is meaningless then do not
implement -V then. following a discussion with millert@

Revision 1.49 / (download) - annotate - [select for diffs], Tue Dec 16 18:38:01 2003 UTC (20 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.48: +7 -7 lines
Diff to previous 1.48 (colored)

avoid name clash with newer libz; breaks on static archs
ok millert@

Revision 1.48 / (download) - annotate - [select for diffs], Tue Dec 9 07:34:55 2003 UTC (20 years, 5 months ago) by millert
Branch: MAIN
Changes since 1.47: +16 -15 lines
Diff to previous 1.47 (colored)

Fixes based on a patch from Moritz Jodeit; mickey@ OK
o break out of inflate() when we hit an error
o fix printf format #ifdef SMALL
o add version string of nullopen.c to -V output
o remove unnecessary initializations to 0 for variables cat and decomp
o beautify -l output to make it line up with the heading

Revision 1.47 / (download) - annotate - [select for diffs], Fri Sep 5 21:03:36 2003 UTC (20 years, 8 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_4_BASE
Branch point for: OPENBSD_3_4
Changes since 1.46: +4 -4 lines
Diff to previous 1.46 (colored)

KNF nit pointed out by theo

Revision 1.46 / (download) - annotate - [select for diffs], Fri Sep 5 20:41:48 2003 UTC (20 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.45: +4 -3 lines
Diff to previous 1.45 (colored)

dont error out when the input file is a symlink AND output goes to stdout
inspired by PR3409, ckuethe@ualberta.ca, tho fixed differently
matches gnu gzip behaviour

ok millert@ tedu@ deraadt@

Revision 1.45 / (download) - annotate - [select for diffs], Fri Sep 5 04:46:35 2003 UTC (20 years, 8 months ago) by tedu
Branch: MAIN
Changes since 1.44: +35 -6 lines
Diff to previous 1.44 (colored)

add a null compressor from canacar@ that lets gzcat work with uncompressed
files.
also introduce SMALLness that removes null and Z compressors to save floppy
space.
ok deraadt@

Revision 1.44 / (download) - annotate - [select for diffs], Tue Aug 5 18:22:17 2003 UTC (20 years, 9 months ago) by deraadt
Branch: MAIN
Changes since 1.43: +4 -4 lines
Diff to previous 1.43 (colored)

spacing

Revision 1.43 / (download) - annotate - [select for diffs], Tue Jul 29 18:33:11 2003 UTC (20 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.42: +6 -3 lines
Diff to previous 1.42 (colored)

Instead of checking for "stdout" in decompress(), just do the check
in list_stats().  Looks cleaner and we don't have to rely on any
special flags being set.

Revision 1.42 / (download) - annotate - [select for diffs], Tue Jul 29 07:09:07 2003 UTC (20 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.41: +3 -3 lines
Diff to previous 1.41 (colored)

Check cat, not pipin when deciding whether or not to make use
"stdout" as the filename in -l mode.  Fixes "gzip -lN < foo.gz"

Revision 1.41 / (download) - annotate - [select for diffs], Sun Jul 27 19:04:22 2003 UTC (20 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.40: +3 -3 lines
Diff to previous 1.40 (colored)

Return FAILURE for "file would grow" case so the .gz file gets removed.
Problem noticed by otto@

Revision 1.40 / (download) - annotate - [select for diffs], Fri Jul 25 20:10:53 2003 UTC (20 years, 9 months ago) by millert
Branch: MAIN
Changes since 1.39: +29 -9 lines
Diff to previous 1.39 (colored)

o deal with the case where -N was specified but no saved mtime in the gz file
o a filename in the header should turn off cat mode if -N
o make setmode() be smart about pipin and not set outfile based on /dev/stdin.
mickey@ OK

Revision 1.39 / (download) - annotate - [select for diffs], Fri Jul 18 20:46:42 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.38: +4 -3 lines
Diff to previous 1.38 (colored)

Previously, "cat" mode (ie: zcat) was set if no input file was specified,
and input was read from the standard input.  However, if the -o option
is specified, we don't need (or want) cat mode since the user has told
us where the output should go.

Revision 1.38 / (download) - annotate - [select for diffs], Fri Jul 18 20:43:18 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.37: +9 -6 lines
Diff to previous 1.37 (colored)

Change "nosave" back into a boolean for improved grokability.
It is now initialized to -1 and, if the user did not specify
the -n or -N flags, is set equal to "decomp".  In other words,
unless overridden via -n/-N, it is false when compressing, and
true when decompressing (which is what we want).

Revision 1.37 / (download) - annotate - [select for diffs], Thu Jul 17 20:06:01 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.36: +182 -84 lines
Diff to previous 1.36 (colored)

o implement -l, -n and -N (including setting outfile + mtime)
o make -v behave like GNU gzip for compress/decompress stats
o write a full gzip header w/ mtime and file name
o for -t/-l just don't write data instead of writing to /dev/null
o exit code is now more consistent with GNU gzip
o a crc error on decompress no longer causes unlink(outfile)
mickey@ OK

Revision 1.36 / (download) - annotate - [select for diffs], Tue Jul 15 19:01:46 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.35: +55 -35 lines
Diff to previous 1.35 (colored)

Don't compress a file that already has a known compression prefix.
This matches GNU gzip behavior.

Revision 1.35 / (download) - annotate - [select for diffs], Mon Jul 14 18:57:31 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.34: +44 -15 lines
Diff to previous 1.34 (colored)

Improved (and cleaner) suffix handling code.  Now "gunzip foo.tgz"
works as expected.  mickey@ OK

Revision 1.34 / (download) - annotate - [select for diffs], Mon Jul 14 18:42:20 2003 UTC (20 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.33: +3 -3 lines
Diff to previous 1.33 (colored)

-t and implied -c due to piped in input is a legal combination of flags

Revision 1.33 / (download) - annotate - [select for diffs], Fri Jul 11 02:31:18 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.32: +21 -21 lines
Diff to previous 1.32 (colored)

Move magic number checking into main.c and make it work when
decompressing from a pipe.  Currently assumes that magic numbers
are 2 bytes but this is relatively easy to change as needed in the
future.  Discussed w/ mickey@

Revision 1.32 / (download) - annotate - [select for diffs], Tue Jul 8 00:30:12 2003 UTC (20 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.31: +51 -33 lines
Diff to previous 1.31 (colored)

fix fd closing logicand close in gzopen(); found by wilfried@ and millert@ ok

Revision 1.31 / (download) - annotate - [select for diffs], Mon Jun 30 03:42:05 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.30: +10 -9 lines
Diff to previous 1.30 (colored)

Make usage() take the exit val are an argument and have the -h flag
use this to exit(0), not exit(1).  Some configure/install sqcripts
check for the existence of gzip by running "gzip -h" and checking
the subshell's exit value.  Noticed by naddy@

Revision 1.30 / (download) - annotate - [select for diffs], Sun Jun 29 21:14:37 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.29: +4 -3 lines
Diff to previous 1.29 (colored)

Return EINVAL on crc failure for gzip and make the driver program
interpret this correctly.  Makes "gzip -t" more useful.  Discussed
with deraadt@

Revision 1.29 / (download) - annotate - [select for diffs], Fri Jun 27 17:33:26 2003 UTC (20 years, 10 months ago) by millert
Branch: MAIN
Changes since 1.28: +3 -2 lines
Diff to previous 1.28 (colored)

Fix -t mode; it needs to set decomp=1 too

Revision 1.28 / (download) - annotate - [select for diffs], Mon Jun 23 19:35:31 2003 UTC (20 years, 11 months ago) by millert
Branch: MAIN
Changes since 1.27: +11 -3 lines
Diff to previous 1.27 (colored)

Fix a typo in my last commit and convert file "-" to /dev/stdin like
GNU gzip does.

Revision 1.27 / (download) - annotate - [select for diffs], Mon Jun 23 16:19:25 2003 UTC (20 years, 11 months ago) by millert
Branch: MAIN
Changes since 1.26: +4 -4 lines
Diff to previous 1.26 (colored)

When trying to cat a non-file, say "foo not a regular file" instead of
"foo not a regular file: unchanged" since we never change the file
in cat mode.

Revision 1.26 / (download) - annotate - [select for diffs], Sun Jun 22 22:17:46 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.25: +3 -3 lines
Diff to previous 1.25 (colored)

man page changes from jmc: use this as gzip too

Revision 1.25 / (download) - annotate - [select for diffs], Sun Jun 22 15:22:43 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.24: +12 -10 lines
Diff to previous 1.24 (colored)

knf and ansi

Revision 1.24 / (download) - annotate - [select for diffs], Tue Jun 10 22:20:45 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.23: +11 -27 lines
Diff to previous 1.23 (colored)

mostly ansi cleanup; pval ok

Revision 1.23 / (download) - annotate - [select for diffs], Wed Jun 4 04:55:58 2003 UTC (20 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.22: +5 -6 lines
Diff to previous 1.22 (colored)

4 was deleted, should be 3

Revision 1.22 / (download) - annotate - [select for diffs], Mon Apr 7 20:55:33 2003 UTC (21 years, 1 month ago) by deraadt
Branch: MAIN
Changes since 1.21: +4 -4 lines
Diff to previous 1.21 (colored)

strlcpy; from Hans-Joerg.Hoexer@yerbouti.franken.de

Revision 1.21 / (download) - annotate - [select for diffs], Tue Jan 7 18:48:06 2003 UTC (21 years, 4 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_3_BASE, OPENBSD_3_3
Changes since 1.20: +17 -17 lines
Diff to previous 1.20 (colored)

Avoid trashing an existing output file when the input cannot be read.
Changes open order slightly and makes a distiction between errors
< 0 and > 0.  Prompted by a discussion on the freebsd-audit list.

Revision 1.20 / (download) - annotate - [select for diffs], Mon Jan 6 18:09:22 2003 UTC (21 years, 4 months ago) by mickey
Branch: MAIN
Changes since 1.19: +9 -8 lines
Diff to previous 1.19 (colored)

fix aproblem w/ -oct mix check and compressing /dev/stdin; millert@ ok

Revision 1.19 / (download) - annotate - [select for diffs], Tue Dec 17 16:16:08 2002 UTC (21 years, 5 months ago) by millert
Branch: MAIN
Changes since 1.18: +120 -81 lines
Diff to previous 1.18 (colored)

o Implement -r (recursive) option
o add missing options to OPTSTRING
o add some option mixing sanity checks
o truncate existing files when uncompressing
o fixed some problems with suffix handling
This brings us closer to being able to replace GNU gzip; mickey@ OK

Revision 1.18 / (download) - annotate - [select for diffs], Sun Dec 8 16:07:54 2002 UTC (21 years, 5 months ago) by mickey
Branch: MAIN
Changes since 1.17: +196 -123 lines
Diff to previous 1.17 (colored)

grop long option names, like gzip.
add most of the gzip's options (a few unimplemented yet).
some cleaning, etc.
millert@ ok

Revision 1.17 / (download) - annotate - [select for diffs], Sat Feb 16 21:27:45 2002 UTC (22 years, 3 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_2_BASE, OPENBSD_3_2, OPENBSD_3_1_BASE, OPENBSD_3_1
Changes since 1.16: +13 -13 lines
Diff to previous 1.16 (colored)

Part one of userland __P removal.  Done with a simple regexp with some minor hand editing to make comments line up correctly.  Another pass is forthcoming that handles the cases that could not be done automatically.

Revision 1.16 / (download) - annotate - [select for diffs], Mon Nov 19 19:02:13 2001 UTC (22 years, 6 months ago) by mpech
Branch: MAIN
Changes since 1.15: +14 -14 lines
Diff to previous 1.15 (colored)

kill more registers

millert@ ok

Revision 1.15 / (download) - annotate - [select for diffs], Tue Dec 12 16:23:27 2000 UTC (23 years, 5 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_3_0_BASE, OPENBSD_3_0, OPENBSD_2_9_BASE, OPENBSD_2_9
Changes since 1.14: +3 -3 lines
Diff to previous 1.14 (colored)

Fix call to getopt(3) -- -S takes an argument; mpech@prosoft.org.lv

Revision 1.13.2.1 / (download) - annotate - [select for diffs], Fri Oct 6 21:16:11 2000 UTC (23 years, 7 months ago) by jason
Branch: OPENBSD_2_7
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (colored) next main 1.14 (colored)

Pull in patch from current (even more to come):
Fix (millert):
warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant).  These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).

Revision 1.14 / (download) - annotate - [select for diffs], Fri Jun 30 16:00:12 2000 UTC (23 years, 10 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_2_8_BASE, OPENBSD_2_8
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (colored)

warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant).  These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).

Revision 1.13 / (download) - annotate - [select for diffs], Fri Mar 10 06:53:51 2000 UTC (24 years, 2 months ago) by d
Branch: MAIN
CVS Tags: OPENBSD_2_7_BASE
Branch point for: OPENBSD_2_7
Changes since 1.12: +3 -2 lines
Diff to previous 1.12 (colored)

plug leak

Revision 1.12 / (download) - annotate - [select for diffs], Sun Sep 26 17:35:49 1999 UTC (24 years, 7 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_2_6_BASE, OPENBSD_2_6
Changes since 1.11: +6 -6 lines
Diff to previous 1.11 (colored)

remove unneeded changes

Revision 1.11 / (download) - annotate - [select for diffs], Sun Sep 26 14:04:58 1999 UTC (24 years, 7 months ago) by espie
Branch: MAIN
Changes since 1.10: +8 -8 lines
Diff to previous 1.10 (colored)

read/write, and compressor->read/write results are signed values.
Adjust types and error checks, so that error checking actually occurs.

[This lets cat garbage|zcat   correctly detect bad headers instead of
dumping core]

Revision 1.10 / (download) - annotate - [select for diffs], Thu Sep 10 06:44:41 1998 UTC (25 years, 8 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE, OPENBSD_2_4
Changes since 1.9: +3 -2 lines
Diff to previous 1.9 (colored)

proper strncpy

Revision 1.9 / (download) - annotate - [select for diffs], Tue Mar 10 16:34:03 1998 UTC (26 years, 2 months ago) by mickey
Branch: MAIN
CVS Tags: OPENBSD_2_3_BASE, OPENBSD_2_3
Changes since 1.8: +7 -6 lines
Diff to previous 1.8 (colored)

fix coredump on pipe to uncompress

Revision 1.8 / (download) - annotate - [select for diffs], Fri Feb 13 16:36:24 1998 UTC (26 years, 3 months ago) by millert
Branch: MAIN
Changes since 1.7: +3 -3 lines
Diff to previous 1.7 (colored)

Don't do chflags() if st_flags is zero.  Fixes bogus error when
uncompressing on an NFS filesystem.  Noted by hubertf@channel.regensburg.org

Revision 1.7 / (download) - annotate - [select for diffs], Tue Aug 19 06:32:36 1997 UTC (26 years, 9 months ago) by denny
Branch: MAIN
CVS Tags: OPENBSD_2_2_BASE, OPENBSD_2_2
Changes since 1.6: +33 -8 lines
Diff to previous 1.6 (colored)

Check length of filename.Z against PATH_MAX and NAME_MAX (POSIX 1003.2 spec)

Revision 1.6 / (download) - annotate - [select for diffs], Sat Jul 19 19:08:28 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.5: +3 -3 lines
Diff to previous 1.5 (colored)

initialization overwrites program name parsing

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jul 8 10:06:31 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.4: +4 -3 lines
Diff to previous 1.4 (colored)

one tiny change

Revision 1.4 / (download) - annotate - [select for diffs], Tue Jul 8 03:13:19 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.3: +4 -4 lines
Diff to previous 1.3 (colored)

restore compress to terminal
fix faild outfile unlink

Revision 1.3 / (download) - annotate - [select for diffs], Sun Jul 6 22:03:34 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.2: +40 -18 lines
Diff to previous 1.2 (colored)

fix error handling

Revision 1.2 / (download) - annotate - [select for diffs], Sun Jul 6 20:47:32 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN
Changes since 1.1: +4 -4 lines
Diff to previous 1.1 (colored)

correct program name decoding

Revision 1.1 / (download) - annotate - [select for diffs], Sun Jul 6 20:22:58 1997 UTC (26 years, 10 months ago) by mickey
Branch: MAIN

do gzip

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.