History log of /freebsd-11-stable/usr.bin/gzip/gzip.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 343251 21-Jan-2019 delphij

MFC r342845,342846: Port NetBSD improvements:

- Add -l support for xz files
- Add lzip support to gzip based on the example lzip decoder.

Obtained from: NetBSD
Relnotes: yes


# 337521 09-Aug-2018 delphij

MFC r336121+r336127(cem): Don't delete outfile unconditionally.


# 336661 24-Jul-2018 delphij

MFC r336156:

Use endian.h le32dec() instead of rolling our own.

Suggested by: phk
Reviewed by: imp, pfg
Differential Revision: https://reviews.freebsd.org/D16192


# 336323 16-Jul-2018 pfg

MFC r336113:
gzip: fix for undefined behavior.

Unportable left shift reported with MKSANITIZER=yes
USE_SANITIZER=undefined:

# progress -zf ./games.tgz tar -xp -C "./" -f -
/public/src.git/usr.bin/gzip/gzip.c:2126:33: runtime error: left shift of
251 by 24 places cannot be represented in type 'int'
100%
|****************************************************************************************************************|
44500 KiB 119.69 MiB/s 00:00 ETA

Refactor the following code into something that is more clear
and fix signed integer shift, by casting all buf[] elements to
(unsigned int):

unsigned char buf[8];
uint32_t usize;
[...]
else {
usize = buf[4] | buf[5] << 8 |
buf[6] << 16 | buf[7] << 24;
[...]

New version:

usize = buf[4];
usize |= (unsigned int)buf[5] << 8;
usize |= (unsigned int)buf[6] << 16;
usize |= (unsigned int)buf[7] << 24;

Only the "<< 24" part needs explicit cast, but for consistency make the
integer promotion explicit and clear to a code reader.

Sponsored by <The NetBSD Foundation>

Obtained from: NetBSD (CVS rev. 1.113)


# 330449 05-Mar-2018 eadler

MFC r326276:

various: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 327191 26-Dec-2017 delphij

MFC r326791: Close the correct file descriptor.


# 326559 05-Dec-2017 delphij

MFC r326052: Support SIGINFO.

Obtained from: NetBSD


# 312072 13-Jan-2017 kib

MFC r311522:
Use type-independent formats for printing nlink_t and ino_t.


# 309850 11-Dec-2016 delphij

MFC r304875:

Use printable ASCII instead of octal representation.


# 307697 20-Oct-2016 araujo

MFC r303541, r303542, r303543, r303545, r303546, r303547, r304225, r304226, r304605, r304676, r305212, r305863:

r303541:
Use nitems() from sys/param.h.

Sponsored by: gandi.net (BSD Day Taiwan)
MFC after: 2 weeks.

r303542:
Use nitems() from sys/param.h.

MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)

r303543:
Use nitems() from sys/param.h.

MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)

r303545:
Use nitems() from sys/param.h.

MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)

r303546:
Use nitems() from sys/param.h.

MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)

r303547:
Use nitems() from sys/param.h.

MFC after: 2 weeks.
Sponsored by: gandi.net (BSD Day Taiwan)

r304225:
Use nitems() from sys/param.h.

MFC after: 2 weeks.

r304226:
Use nitems() from sys/param.h.

MFC after: 2 weeks.

r304605:
Fix calloc(3) argument order.

Reviewed by: trasz
MFC after: 4 weeks.
Differential Revision: https://reviews.freebsd.org/D7532

r304676:
Fix calloc(3) argument order.

MFC after: 4 weeks.

r305212:
- Invert calloc(3) argument order.

MFC after: 4 weeks

r305863:
Invert calloc(3) argument order.

Reviewed by: ed.
MFC after: 4 weeks.
Differential Revision: https://reviews.freebsd.org/D7902


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 290073 27-Oct-2015 delphij

Update NetBSD RCS IDs to reflect the changes being upstreamed.

MFC after: 13 days
X-MFC-With: r290024


# 290024 26-Oct-2015 delphij

In gunzip(1), treat trailing garbage as a warning and not an error. This
allows scripts to distinguish it between real fatal errors, for instance a
CRC mismatch.

Update manual page for the behavior change.

PR: bin/203873
Submitted by: Eugene Grosbein <eugen grosbein net>
MFC after: 2 weeks


# 281626 16-Apr-2015 delphij

r281540 was upstreamed as NetBSD r1.108 of gzip.c, note it as merged.


# 281540 14-Apr-2015 delphij

When reading in the original file name from gzip header, we read
in PATH_MAX + 1 bytes from the file. In r281500, strrchr() is
used to strip possible path portion of the file name to mitigate
a possible attack. Unfortunately, strrchr() expects a buffer
that is NUL-terminated, and since we are processing potentially
untrusted data, we can not assert that be always true.

Solve this by reading in one less byte (now PATH_MAX) and
explicitly terminate the buffer after the read size with NUL.

Reported by: Coverity
CID: 1264915
X-MFC-with: 281500
MFC after: 13 days


# 281500 13-Apr-2015 delphij

Sync with NetBSD:

- Mention xz(1) in gzip(1).
- Strip away path from header name when decompressing.

MFC after: 2 weeks


# 278896 17-Feb-2015 jilles

compress,gzip,xz: Preserve timestamps with nanosecond precision.


# 273507 22-Oct-2014 delphij

Sync with NetBSD.

MFC after: 2 weeks


# 226184 10-Oct-2011 delphij

Incorporate recent changes from NetBSD. Most notable change is the addition
of support of decompressing xz files.

Obtained from: NetBSD


# 222287 25-May-2011 delphij

Fix a regression introduced with previous changeset: if output is stdout,
do not check for symbolic link.


# 222211 23-May-2011 delphij

Match symbolic link handling behavior with GNU gzip, bzip2 and xz:

When we are operating on a symbolic link pointing to an existing
file, bail out by default, but go ahead if -f is specified.

Submitted by: arundel
MFC after: 2 weeks


# 222210 23-May-2011 delphij

Diff reduction against NetBSD. The most notable change is to zdiff(1) to
handle more file formats including bzip2 and xz.

MFC after: 2 weeks


# 213927 16-Oct-2010 bcr

Correct some typos in comments, no functional changes.


# 213044 22-Sep-2010 delphij

In the past gunzip(1) write()'s after each inflate return. This is
not optimal from a performance standpoint since the write buffer is
not necessarily be filled up when the inflate rountine reached the
end of input buffer and it's not the end of file.

This problem gets uncovered by trying to pipe gunzip -c output to
a GEOM device directly, which enforces the writes be multiple of
sector size.

Sponsored by: iXsystems, Inc.
Reported by: jpaetzel
MFC after: 2 weeks


# 209017 10-Jun-2010 delphij

Several style fixes as prompted by bde@.

While I'm there, loosen the st_nlink check and fix grammar for 1 extra
links.


# 208889 07-Jun-2010 delphij

Follow up revision 208888 with purely ident changes.

MFC after: 1 week


# 208888 07-Jun-2010 delphij

Correct a bug in gzip(1): make sure that initialize isb with fstat() on
input file before using it.

PR: bin/147275
Submitted by: thomas
MFC after: 1 week


# 207284 27-Apr-2010 delphij

Use _exit(2) system call directly instead of using exit(3) in signal
handler, as the latter is not guaranteed to be signal safe, and we
do not really care about flushing the stream during SIGINT.

Suggested by: Maxim Konovalov <maxim.konovalov gmail com>
MFC after: 13 days


# 207247 26-Apr-2010 delphij

Add a signal handler for SIGINT which removes output file when necessary.

While I'm there, move unlink_input() slightly down to after closing the
output file, in uncompression path.

MFC after: 2 weeks


# 206387 07-Apr-2010 delphij

Diff reduction against NetBSD and add myself to AUTHORS section of the
manual page as I wrote the unpack functionality. No actual executable
code change verified with md5(1).


# 205793 28-Mar-2010 ed

Change all our own code to use st_*tim instead of st_*timespec.

Also remove some local patches to diff(1) which are now unneeded.


# 195988 31-Jul-2009 delphij

Correct a stack underflow in gzip:

- Limit suffix to be no more than 30 bytes long. This matches GNU
behavior.
- Correct usage of memcpy().

Note that this commit only corrects the stack underflow issue, we
still need some other fixes to cover other edges. [1]

Reported by: Ron Jude <ronj wytheville org>
Discussed with: Matthew Green (original NetBSD gzip author),
Eygene Ryabinkin <rea-fbsd codelabs ru> [1]
Approved by: re (kib)


# 194916 24-Jun-2009 delphij

Sync with NetBSD:
- gzip -n does not store timestamp; [1]
- Reduce diff against NetBSD by moving some casts in our local
versions.

PR: bin/134955
Obtained from: NetBSD
MFC after: 1 month


# 194579 21-Jun-2009 delphij

Add support for uncompressing pack(1)'ed files. Pack(1) is a program found
in some commercial Unix systems, which utilizes Huffman minimum redundancy
code tree to compress files. This implementation supports the "new" pack
format only, just like GNU gzip did.

Thanks for oliver@'s archive set which I can test against, and Mingyan Guo
for providing helpful review of my code.

PR: bin/109567
MFC after: 1 month


# 194508 19-Jun-2009 delphij

Two fixes for SMALL case when compiling with WARNS=6:

- Reduce scope where return value can be referenced.
- Add a dummy access to timestamp to silence warning.

Submitted by: Mingyan Guo <guomingyan gmail com>


# 181283 04-Aug-2008 cperciva

Mark functions as __dead2 in order to help the LLVM static checker
understand which code paths aren't possible.

Reported by: edwin


# 180727 22-Jul-2008 delphij

Sync with NetBSD's license changes.


# 176980 09-Mar-2008 rwatson

Teach gunzip that .tbz and .tbz2 uncompress to .tar, in a manner similar to
its existing understanding that .tgz uncompresses to .tar.

MFC after: 3 days
PR: 121519
Submitted by: Ighighi <ighighi at gmail.com>


# 176970 09-Mar-2008 rwatson

When gzipping to a target file, only set the source file flags on the
target file after the timestamp has been set; otherwise setting the
timestamp will fail if the flags don't permit it (i.e., uchg).

MFC after: 1 week
PR: 120208
Submitted by: Ighighi <ighighi at gmail.com>


# 171389 11-Jul-2007 delphij

- Simulate GNU gzip(1) behavior where full filename is
being output in verbose mode when doing recursive[1].
- Use better representation of S:

PR: bin/114470
Submitted by: Ighighi <ighighi gmail com> [1]
Approved by: re (hrs)


# 170053 28-May-2007 delphij

Add a '-k' flag which is similar with its bzip2(1) counterpart,
meaning that the user wants the input file to be left intact.

Feature request: Ighighi <ighighi gmail.com>
PR: bin/103006
MFC after: 1 month


# 166363 31-Jan-2007 delphij

Fix typo.

Obtained from: DragonFly


# 166255 26-Jan-2007 delphij

Replace the GNU gzip with a slightly modified NetBSD gzip. The
NetBSD version is a feature-to-feature re-implementation of GNU
gzip using the freely-redistributable zlib and this version is
expected to be mostly bug-to-bug compatible with the GNU
implementation.

- Because this is a piece of mature code and we want to make
changes so it is added directly rather than importing to
src/contrib.
- Connect newly added code to src/usr.bin/ and rescue/rescue
build.
- Disconnect the GNU gzip code from build for now, they will
be eventually removed completely.
- Provide two new src.conf(5) knobs, WITHOUT_BZIP2_SUPPORT and
WITHOUT_BZIP2.

Tested by: kris (full exp-7 pointyhat build)
Approved by: core (importing a 4-clause BSD licensed file)
Approved by: re (adding new utility during -HEAD code slush)