these problems:
1) gzip -vt just prints the contents of a .Z file
2) gzip -vt will print OK even if the .gz file is corrupt
3) gzip -vt prints nothing with a .bz2 file
4) gzip can loop endlessly with a corrupt .bz2 file
all the install media used the 'SMALL' variant, but this is not the case.
Redo the percentage print code to reduce the size to less than the old version.
Fix another fd leakage (didn't call fclose() if ferror() returned non-zero.
Change some maybe_warn() to maybe_warnx() in places I'm sure errno is undefined.
Call mayber_warn() earlier in other paths so that errno might still be valid.
Make the SMALL and NO_BZIP/COMPRESS_SUPPORT options all compile with WARNS=3.
Rework logic of gz_{un}compress to make it much less likely to leak fds
(at least 2 non-error paths leaked them!)
Make -S ".xyz" and -S "" both do something sensible.
Make in-situ compression work - only lose the file on error.
Pass an open fd to zopen (renamed zdopen) to avoid fd leakage (was badly borked)
Write header into first 64k output block to writes are aligned.
(more efficient and might avoid some problem with code that doesn't
like receiving partial buffers)
Check file size on compression - double checks against fs full.
Remove some pointless casts, and otherwise simplify some logic.
fixes PR#26246.
- if crc/len are wrong, be sure to noticed it failed
- in check_suffixes(), be sure not to underrun an array (from yamt)
- don't fail so badly on short header, from and fixes R#26242 (also
from yamt)
- more underrun avoidance in file_uncompress(). fixes PR#26241.
- check each gzip-part's length against the original and warn if it's
wrong. fixes part of PR#26233.
- check the input crc32. fixes the rest of PR#26233.
- fix any decompression on corrupted gzip files. PR#25508
- ask to overwrite files if we have a tty, rather than failing the
operation. PR#25509.
- clean up maybe_err()/maybe_warn(): use maybe_err() only for fatal
errors. maybe_warn() is for processing errors. this allows
"gzip -d file1.gz file2.gz" to decompress file2.gz even if file1.gz
is corrupted, etc.
- change the internal compressor/decompressor API to return "-1" on
failure, not 0. this allows for 0-sized files to be decompressed
correctly.
definitions shadowing other variables.
Pass storage for file names into the file_compress and file_uncompress
functions, so that we don't run the risk of leaking memory. Remove a global
variable that's no longer needed.
name when gunzip'ing via strdup(3). Fixes a bug whereby the new
filename would appear as gibberish when verbosely gunzipping.
Fix an off-by-one error when allocating the filename with added suffix,
and properly NUL-terminate the new filename.
It's NULL, not 0, in char * assignments - there are some still to do here.
anymore, use the low-level inflate()/deflate() directly. this
allows support file-type detection on stdin; now can decompress
.Z and .bz2 files fed to stdin (fixes PR#25192) additionally it
makes -v work with stdin or stdout (fixes PR#25215.)
(with these changes, we no longer need gzopenfull(3) in libz.)
thanks to martin@ for the code gzip.c:gz_uncompress() is based on.