summaryrefslogtreecommitdiff
path: root/usr.bin/compress
AgeCommit message (Collapse)Author
2023-11-11Ignore -N in "gzip -dN <in.gz" and "zcat -N in.gz"George Koehler
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@
2023-08-11Replace use of the old BSD st_*timespec members in struct stat withPhilip Guenther
the POSIX-standard st_*tim members. ok millert@
2022-12-26spelling fixes; from paul tagliamonteJason McIntyre
amendments to his diff are noted on tech
2022-10-26compress: fix minor TOCTOU when checking for existing fileTodd C. Miller
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().
2022-10-23The cat_opts and decomp_opts fields in struct compressor are unusedTodd C. Miller
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@
2022-10-22Add support to gunzip for zip files that contain a single member.Todd C. Miller
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.
2022-08-29Fix growth check in compress(1)/gzip(1)Theo Buehler
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
2022-06-18Fix gzip byte counts with 32-bit integersGeorge Koehler
If zlib is without our local change in lib/libz/zlib.h r1.7, then s->z_stream.total_in and s->z_stream.total_out might overflow on architectures where uLong has 32 bits. After overflow, the total would be 4G below the correct total. Calculate our own 64-bit totals. When decompressing, take (uLong)s->z_stream.total_in as a total modulo ULONG_MAX + 1. ok tb@
2022-04-10Print a more accurate message when -v is used with -kJeremie Courreges-Anglas
Report and different proposal by "prx", ok millert@
2022-03-14add -k flag to gzip and gunzipSolene Rapenne
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@
2021-01-18Move definition of pmode to main.c instead of a compress.h. Avoids linkermortimer
issues with -fno-common. ok deraadt@
2020-10-12Accommodate POSIX basename(3) that takes a non-const parameter andChristian Weisgerber
may modify the string buffer. ok millert@
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
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.
2019-05-27For "gunzip -N", only use the basename of the stored path.Todd C. Miller
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@
2019-01-25I am retiring my old email address; replace it with my OpenBSD one.Todd C. Miller
2017-05-29Remove unused zclose function.Frederic Cambus
From Brian Callahan, thanks! OK tb@
2016-09-03remove parens from method callsTed Unangst
2016-09-03the SMALL code made a half hearted effort to exclude compression codeTed Unangst
but some of the write code remained. shuffle things around a bit to make the exclusion more complete.
2016-09-03start pulling apart some function pointers that take too many parametersTed Unangst
because of excessive code sharing. compression and decompression are not entirely similar, they should share less. ok joerg millert
2016-08-17When returning the file size info, only use z_total_in/z_total_outTodd C. Miller
for the read (inflate) case where there might be multiple streams. For the write (deflate) case there can only be a single stream so just use the per-stream total_in/total_out. Fixes "gzip -v" byte counts. OK henning@.
2016-07-14make several program to use "chown" promise.Sebastien Marie
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.
2016-04-29Need to set in/out bytes count for gz_write too. Otherwise gzipTodd C. Miller
will think the resulting file was got larger during compression.
2016-04-28Account for multiple streams in "gzip -l" output. This fixes "gzipTodd C. Miller
-l" output when used on package files. OK espie@ deraadt@
2016-03-30for some time now mandoc has not required MLINKS to functionJason McIntyre
correctly - logically complete that now by removing MLINKS from base; authors need only to ensure there is an entry in NAME for any function/ util being added. MLINKS will still work, and remain for perl to ease upgrades; ok nicm (curses) bcook (ssl) ok schwarze, who provided a lot of feedback and assistance ok tb natano jung
2015-10-17Tighten pledge: We only write to stdio and never to any files ifChristian Weisgerber
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@
2015-10-09Change all tame callers to namechange to pledge(2).Theo de Raadt
2015-10-04Also needs "rpath" for some circumstances.Theo de Raadt
2015-10-03gzip can use tame "stdio wpath cpath fattr". this blocks a lot ofTheo de Raadt
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?
2015-08-30Ignore setuid/setgid settings from a compress/gzip file; original CSRGTheo de Raadt
code. Found by trondd exercising coverage of tame in gzip. ok guenther millert kettenis
2015-08-20Do not cast result of malloc/calloc/realloc* if stdlib.h is in scopeTheo de Raadt
ok krw millert
2015-06-25Put fts_close() where missing.Masao Uebayashi
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@
2015-05-03Preserve times to nanosecond precision instead of just microsecond.Philip Guenther
Prefer to set attributes by fd for regular files, and not follwing symlinks for others. ok brynet@ millert@
2015-04-09Both more and less accept options beginning with '+'.Todd C. Miller
From Tim van der Molen
2015-02-01KNF whitespace fix and handle funopen error case.Tobias Stoeckmann
ok millert
2015-01-16Replace <sys/param.h> with <limits.h> and other less dirty headers whereTheo de Raadt
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)
2014-10-08userland reallocarray audit.Doug Hogan
Replace malloc() and realloc() calls that may have integer overflow in the multiplication of the arguments with reallocarray(). ok deraadt@
2014-10-07no more Xr to gzsigTheo de Raadt
2014-05-08+.Xr less 1 ,Jason McIntyre
2014-05-07When you want more, you say "more". When you want less, you say "less".Vadim Zhukov
When you don't get what you asked for, you get angry. When you add a tiny bit, it should be "more" or "less" still, or you'll get angry. So lets make zmore(1) call more(1) and zless(1) call less(1), as it's supposed to be. okay and input from ingo@, no objections from author AKA millert@
2014-03-17use Ex;Jason McIntyre
2014-01-28make description of gzip(1) exit status codes more accurate.Igor Sobrado
issue pointed out by jmc@, verified by me. ok jmc@
2014-01-28make it clear that -LV are no ops; ok millertJason McIntyre
2014-01-27Remove the no-op flags -L and -V from compress(1), these optionsTodd C. Miller
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@
2014-01-27remove the no-op flags -L and -V from compress(1), these optionsIgor Sobrado
come from GNU zip and they were never in compress(1) until we added gzip(1) support to it. joint work with jmc@ and millert@; millert@ will do the rest. ok jmc@, millert@
2014-01-26- document for uncompress and zcat exit status of 0 or >0 onlyJason McIntyre
- kill an unneccessary Pp that created double vertical space - mention that posix marks these apps xsi - add uncompress -V to the list of extensions - document that posix stipulates a limit of 14 for -b, even though it permits 15 and 16 ok sobrado millert
2013-12-29+.Sh EXIT STATUSJason McIntyre
2013-08-12some minor fixes; From: Jan StaryJason McIntyre
2013-04-17zlib info header is 32-bit; handle for localtime() call; ok millertTheo de Raadt
2012-09-30When outputting to stdout and compressing would grow the file, exitTodd C. Miller
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@
2012-09-26last stage of rfc changes, using consistent Rs/Re blocks, and moving theJason McIntyre
references into a STANDARDS section;