NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/58223: gzip: multiple issues
>Number: 58223
>Category: bin
>Synopsis: gzip: multiple issues
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 04 08:50:00 +0000 2024
>Originator: RVP
>Release: NetBSD-10.99.10
>Organization:
>Environment:
NetBSD-10.99.10 amd64
>Description:
gzip in the current -HEAD has multiple issues:
1. With .xz and .lz files, the -t flag decompresses the file to stdout
instead of just testing the file.
2. It fails to decode certain .lz files compressed at some levels:
lzip -[24789] games.tar
>How-To-Repeat:
Get any of the recent games.tar.xz tarball of -HEAD.
For 1)
$ gzip -t games.tar.{xz,lz}
For 2)
$ for l in {0..9}; do lzip -${l}c games.tar > games.tar.$l.lz; done
$ for f in games.tar.*.lz; do gzip -t $f >/dev/null; done
gzip: games.tar.2.lz: uncompress failed
gzip: games.tar.4.lz: uncompress failed
gzip: games.tar.7.lz: uncompress failed
gzip: games.tar.8.lz: uncompress failed
gzip: games.tar.9.lz: uncompress failed
$
>Fix:
diff -urN gzip.orig/unlz.c gzip/unlz.c
--- gzip.orig/unlz.c 2023-06-10 04:45:25.000000000 +0000
+++ gzip/unlz.c 2024-05-04 08:00:32.963583086 +0000
@@ -295,7 +295,7 @@
size_t size = (size_t)offs;
lz_crc_update(&lz->crc, lz->obuf + lz->spos, size);
- if (fwrite(lz->obuf + lz->spos, 1, size, lz->fout) != size)
+ if (!tflag && fwrite(lz->obuf + lz->spos, 1, size, lz->fout) != size)
return -1;
lz->wrapped = lz->pos >= lz->dict_size;
@@ -602,7 +602,7 @@
lz_get_dict_size(unsigned char c)
{
unsigned dict_size = 1 << (c & 0x1f);
- dict_size -= (dict_size >> 2) * ( (c >> 5) & 0x7);
+ dict_size -= (dict_size >> 4) * ( (c >> 5) & 0x7);
if (dict_size < MIN_DICTIONARY_SIZE || dict_size > MAX_DICTIONARY_SIZE)
return 0;
return dict_size;
diff -urN gzip.orig/unxz.c gzip/unxz.c
--- gzip.orig/unxz.c 2018-10-06 16:36:45.000000000 +0000
+++ gzip/unxz.c 2024-05-04 07:40:02.518116365 +0000
@@ -99,7 +99,7 @@
if (strm.avail_out == 0 || ret != LZMA_OK) {
const size_t write_size = sizeof(obuf) - strm.avail_out;
- if (write(o, obuf, write_size) != (ssize_t)write_size)
+ if (!tflag && write(o, obuf, write_size) != (ssize_t)write_size)
maybe_err("write failed");
strm.next_out = obuf;
Home |
Main Index |
Thread Index |
Old Index