NetBSD Problem Report #58223
From www@netbsd.org Sat May 4 08:49:46 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 8B49D1A923B
for <gnats-bugs@gnats.NetBSD.org>; Sat, 4 May 2024 08:49:46 +0000 (UTC)
Message-Id: <20240504084945.60ED61A923C@mollari.NetBSD.org>
Date: Sat, 4 May 2024 08:49:45 +0000 (UTC)
From: rvp@SDF.ORG
Reply-To: rvp@SDF.ORG
To: gnats-bugs@NetBSD.org
Subject: gzip: multiple issues
X-Send-Pr-Version: www-1.0
>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
>Last-Modified: Sat May 04 13:20:01 +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;
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58223 CVS commit: src/usr.bin/gzip
Date: Sat, 4 May 2024 09:17:04 -0400
Module Name: src
Committed By: christos
Date: Sat May 4 13:17:03 UTC 2024
Modified Files:
src/usr.bin/gzip: unlz.c unxz.c
Log Message:
PR/58223: RVP: Don't write to stdout when testing.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/gzip/unlz.c src/usr.bin/gzip/unxz.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.