From 63dbf6b3b9e6e781df1a6a64e609b10e23969681 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 15 Apr 2026 12:00:17 -0700 Subject: gzip: don’t mishandle .lzh after .Z MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem reported by Michał Majchrowicz. * unlzh.c (read_c_len): Clear left and right when n == 0. --- NEWS | 4 ++++ THANKS | 1 + unlzh.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/unlzh.c b/unlzh.c index 2522764..c3e92ff 100644 --- a/unlzh.c +++ b/unlzh.c @@ -313,6 +307,12 @@ decode_p () static void huf_decode_start () { + /* Needed in case LEFT and RIGHT are reused from a previous + LZW decompression. It may be overkill to clear all of both + arrays, but nobody has had time to analyze this carefully. */ + memzero (left, (2 * NC - 1) * sizeof *left); + memzero (right, (2 * NC - 1) * sizeof *right); + init_getbits(); blocksize = 0; } -- cgit v1.3