* tests/list: Test for this.
* util.c (display_ratio):
Say "-%Inf%" if the compression ratio is negative infinity.
From a suggestion by Mark Adler <https://bugs.gnu.org/79414#13>.
Although EOF == -1 on all known platforms, POSIX and C don’t
guarantee it. Fix code that silently assumes this.
* deflate.c (lm_init, fill_window):
* gzip.c (get_method):
* util.c (fill_inbuf):
Don’t assume EOF == -1, or that converting EOF to unsigned
and back to int yields -1. Instead, statically check
EOF-related assumptions.
* deflate.c (fill_window): Check for more < EOF, not more != EOF.
* unzip.c (DATSIG, L8): New macros.
(unzip): Previously only one of the four possible data descriptors was
handled. Check for all four when validating the uncompressed
data with the CRC and length in the data descriptor. This also now
checks the full eight-byte uncompressed length for zip files.
* unzip.c (bad_zipfile): New static function,
with most of the old contents of check_zipfile.
This is clearer than the trick of having a loop that never loops.
(check_zipfile): Use it.
This fixes bugs in the lack of detection of spanning signatures,
lack of detection of empty zip files, checking the compression
method, failure to skip over the file name and extra field in the
SMALL_MEM case, failure to get the CRC and uncompressed length in
the SMALL_MEM case, failure to check for invalid combinations of
header information, the lack of detection of a Zip64 entry, and
a possible decompression of a zip entry after a gzip member.
* gzip.c (get_method): New arg FIRST. All callers changed.
* gzip.h (PKZIP_MAGIC): Now just the two-byte magic header.
* unzip.c (SPNSIG, ONESIG, Z64SIG, ENDSIG): New macros.
(RAND_HEAD_LEN, decrypt): Remove. All uses removed.
(orig_crc, orig_len): New static vars.
(check_zipfile, unzip): Handle PKZIP signatures and the local header.
This can occur if you define DYNALLOC.
Problem reported by Mohamed Maatallah <https://bugs.gnu.org/78639#13>.
* gzip.c (get_method): Don’t memcmp more bytes than were read.
Also, no need to do two memcmp’s now, or to check inptr.
Problem reported by Mohamed Maatallah <https://bugs.gnu.org/78639>.
* unzip.c (check_zipfile):
Don’t read past end of initialized data in the input buffer.
Problem reported by Xinjian Ma (Bug#78084).
* tests/reference: Skip this test if od does not support -An -tx1
as POSIX requires. Also, omit an unnecessary use of tr, since
the $(...) already does that.
On such systems, treat "more" as optional, just as we treat "less".
If the primary program is not available, do not install zmore.
Reported by Bruno Haible in http://debbugs.gnu.org/77563 and noticed
on a 2025 x86_64 GNU/Hurd system.
* configure.ac: Check for more/MORE just like we do for less/LESS.
* tests/Makefile.am: Use the new variables.
* NEWS: Mention it.
This is slimmed down from the originally proposed patch, which
ignored GZIP entirely. Thanks to Lasse Collin for thoughtful comments.
* gzip.c (ENV_OPTION): Remove. All uses removed.
(main): Parse GZIP contents with error diagnostics disabled,
and simply ignore invalid contents. Ignore all options
except -1 thru -9, --rsyncable, --synchronous. Remove
unnecessary longind local; all uses removed.
* tests/gzip-env (GZIP): Adjust to match current behavior.
Also test --rsyncable, --synchronous.
Suggested by Sam Russell (Bug#74192).
* bootstrap.conf (gnulib_modules): Depend on crc-x86_64, not just crc.
* NEWS, THANKS, lib/.gitignore, m4/.gitignore:
Update accordingly.
* dfltcc.c (dfltcc_inflate): The previous patch was incorrect, as
fill_inbuf (0) will not call flush_outbuf which is needed here.
Problem and fix reported by Eduard Stefes in
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=75924#13>.
Although this patch causes the hufts test to fail, that might be
due to a different bug in the s390 code, so let’s leave that test
alone for now.
* bootstrap.conf (gnulib_modules): The deprecated realloc-gnu module
cannot be renamed to realloc-gnu-h (which doesn't exist), but rather
to realloc-posix. Spotted by Collin Funk.
* bootstrap.conf: Some gnulib modules are now deprecated in favor of
new names with a "-h" suffix. Induce this change with the following:
re='inttypes|realloc-gnu|sys_stat'
perl -pi -e 's{^('"$re"')$}{$1-h}' bootstrap.conf
* tests/synchronous: Test that --synchronous works. This
failed with musl 1.2.5 before the Gnulib commit 0fb185b7cd5e
("fcntl-h: port better to musl on GNU/Linux").
* tests/Makefile.am (TESTS): Add it.
* lib/Makefile.am (MAINTAINERCLEANFILES): Initialize to empty.
Gnulib expects it to be set as it appends values to it, the recent
upgrade to lib/crc.c modifies this and building fails if it isn't
already set before gnulib.mk is included.
POSIX says ‘type’ is an XSI extension, whereas ‘command -v’ is
part of the base. Problem reported by Clarence “Sparr” Risher in
<https://bugs.gnu.org/73402>.
* gzexe.in, tests/help-version, zdiff.in, zgrep.in:
Use ‘command -v’, not ‘type’.
* tests/reference: Don't rely on od's -w option.
Instead, use tr -d '\n' to join the output lines.
Reported by Bruno Haible in https://bugs.gnu.org/73140
* bootstrap.conf (gnulib_modules): Add crc.
* util.c: Include "crc.h".
(crc_32_tab): Delete. No longer used.
(updcrc): Use gnulib's crc32_update.
(crc): Initialize the global to 0, not 0xffffffffL.
(setcrc, getcrc): Stop flipping bits. No longer needed.
* lib/.gitignore: Add crc.c and crc.h, and sort.