Module Name: src Committed By: martin Date: Mon Oct 14 18:13:36 UTC 2024
Modified Files: src/tests/usr.bin/gzip [netbsd-9]: t_gzip.sh src/usr.bin/gzip [netbsd-9]: unlz.c unxz.c Log Message: Pull up following revision(s) (requested by christos in ticket #1913): usr.bin/gzip/unlz.c: revision 1.10 usr.bin/gzip/unlz.c: revision 1.9 usr.bin/gzip/unxz.c: revision 1.9 tests/usr.bin/gzip/t_gzip.sh: revision 1.2 PR/58223: RVP: Don't write to stdout when testing. PR/58233: RVP: Fix lzip dictionary size calculation Add a test for PR/58223 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.1.36.1 src/tests/usr.bin/gzip/t_gzip.sh cvs rdiff -u -r1.6 -r1.6.6.1 src/usr.bin/gzip/unlz.c cvs rdiff -u -r1.8 -r1.8.2.1 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.
Modified files: Index: src/tests/usr.bin/gzip/t_gzip.sh diff -u src/tests/usr.bin/gzip/t_gzip.sh:1.1 src/tests/usr.bin/gzip/t_gzip.sh:1.1.36.1 --- src/tests/usr.bin/gzip/t_gzip.sh:1.1 Sat Mar 17 16:33:13 2012 +++ src/tests/usr.bin/gzip/t_gzip.sh Mon Oct 14 18:13:36 2024 @@ -1,4 +1,4 @@ -# $NetBSD: t_gzip.sh,v 1.1 2012/03/17 16:33:13 jruoho Exp $ +# $NetBSD: t_gzip.sh,v 1.1.36.1 2024/10/14 18:13:36 martin Exp $ # # Copyright (c) 2008 The NetBSD Foundation, Inc. # All rights reserved. @@ -100,6 +100,22 @@ EOF atf_check gzip -d good.gz } +atf_test_case lzip +lzip_head() +{ + atf_set "descr" "Checks lzip compression levels (PR/58223)" +} +lzip_body() +{ + n=games.tar + tar -C /usr/games -cf games.tar . + for i in $(jot 10 0 9); do + f=$n.$i.lz + lzip -$ic < $n > $f + gunzip -t $f > /dev/null + done +} + atf_init_test_cases() { atf_add_test_case concatenated @@ -107,4 +123,5 @@ atf_init_test_cases() atf_add_test_case truncated atf_add_test_case crcerror atf_add_test_case good + atf_add_test_case lzip } Index: src/usr.bin/gzip/unlz.c diff -u src/usr.bin/gzip/unlz.c:1.6 src/usr.bin/gzip/unlz.c:1.6.6.1 --- src/usr.bin/gzip/unlz.c:1.6 Sun Nov 11 01:42:36 2018 +++ src/usr.bin/gzip/unlz.c Mon Oct 14 18:13:36 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: unlz.c,v 1.6 2018/11/11 01:42:36 christos Exp $ */ +/* $NetBSD: unlz.c,v 1.6.6.1 2024/10/14 18:13:36 martin Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -295,7 +295,7 @@ lz_flush(struct lz_decoder *lz) 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 @@ static unsigned 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; Index: src/usr.bin/gzip/unxz.c diff -u src/usr.bin/gzip/unxz.c:1.8 src/usr.bin/gzip/unxz.c:1.8.2.1 --- src/usr.bin/gzip/unxz.c:1.8 Sat Oct 6 16:36:45 2018 +++ src/usr.bin/gzip/unxz.c Mon Oct 14 18:13:36 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: unxz.c,v 1.8 2018/10/06 16:36:45 martin Exp $ */ +/* $NetBSD: unxz.c,v 1.8.2.1 2024/10/14 18:13:36 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: unxz.c,v 1.8 2018/10/06 16:36:45 martin Exp $"); +__RCSID("$NetBSD: unxz.c,v 1.8.2.1 2024/10/14 18:13:36 martin Exp $"); #include <stdarg.h> #include <errno.h> @@ -99,7 +99,8 @@ unxz(int i, int o, char *pre, size_t pre 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;