gzip: fix CVE-2026-41992

Backport upstream fix for a global buffer overflow in the LZH
decompression logic (unlzh.c). The left[] and right[] global arrays
shared across LZW and LZH decompression routines are not reinitialized
between files processed in the same invocation, allowing an
out-of-bounds read in the LZH decoder.

Adapted for gzip 1.13:
- Refreshed NEWS and THANKS hunks to match 1.13 release context.

Reference: https://nvd.nist.gov/vuln/detail/CVE-2026-41992
(From OE-Core rev: db470c65798b4a90a5c1c333d61f3a531cca75cc)

Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit deaaaacabbf8d21fb9271e3f6f83055893510cff)
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Paul Barker <paul@pbarker.dev>
This commit is contained in:
Jaipaul Cheernam
2026-07-08 20:55:44 +02:00
committed by Paul Barker
parent 9a906f991a
commit 865d0fd2d6
2 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
From 63dbf6b3b9e6e781df1a6a64e609b10e23969681 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 15 Apr 2026 12:00:17 -0700
Subject: =?UTF-8?q?gzip:=20don=E2=80=99t=20mishandle=20.lzh=20after=20.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.
CVE: CVE-2026-41992
Upstream-Status: Backport [https://cgit.git.savannah.gnu.org/cgit/gzip.git/commit/?id=63dbf6b3b9e6e781df1a6a64e609b10e23969681]
Signed-off-by: Jaipaul Cheernam <jaipaul.cheernam@est.tech>
---
NEWS | 4 ++++
THANKS | 1 +
unlzh.c | 6 ++++++
3 files changed, 11 insertions(+)
diff --git a/NEWS b/NEWS
index bdb7cc0..af2a08f 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ GNU gzip NEWS -*- outline -*-
** Bug fixes
+ A buffer overflow has been fixed when decompressing an .lzh file
+ after decompressing a .Z file.
+ [bug present since the beginning]
+
'gzip -d' no longer fails to report invalid compressed data
that uses a dictionary distance outside the input window.
[bug present since the beginning]
diff --git a/THANKS b/THANKS
index 4e545d9..a7d25e4 100644
--- a/THANKS
+++ b/THANKS
@@ -186,6 +186,7 @@ Jamie Lokier u90jl@ecs.oxford.ac.uk
Richard Lloyd R.K.Lloyd@csc.liv.ac.uk
David J. MacKenzie djm@eng.umd.edu
John R MacMillan john@chance.gts.org
+Michał Majchrowicz mmajchrowicz@afine.com
Ron Male male@eso.mc.xerox.com
Jakub Martisko jamartis@redhat.com
Don R. Maszle maze@bea.lbl.gov
diff --git a/unlzh.c b/unlzh.c
index 3320196..a6cf109 100644
--- a/unlzh.c
+++ b/unlzh.c
@@ -232,6 +232,12 @@ read_c_len ()
c = getbits(CBIT);
for (i = 0; i < NC; i++) c_len[i] = 0;
for (i = 0; i < 4096; i++) c_table[i] = c;
+
+ /* 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 *left);
} else {
i = 0;
while (i < n) {

View File

@@ -6,6 +6,7 @@ LICENSE = "GPL-3.0-or-later"
SRC_URI = "${GNU_MIRROR}/gzip/${BP}.tar.gz \
file://run-ptest \
file://CVE-2026-41992.patch \
"
SRC_URI:append:class-target = " file://wrong-path-fix.patch"