blob: 16c229574c41213beceb34efc2c7ac594cef42e2 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 28a9dc642ffd759df1e48be247a114f440a6c16e Mon Sep 17 00:00:00 2001
2From: Nick Wellnhofer <wellnhofer@aevum.de>
3Date: Mon, 30 Jul 2018 13:14:11 +0200
4Subject: [PATCH] Fix infinite loop in LZMA decompression
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Check the liblzma error code more thoroughly to avoid infinite loops.
10
11Closes: https://gitlab.gnome.org/GNOME/libxml2/issues/13
12Closes: https://bugzilla.gnome.org/show_bug.cgi?id=794914
13
14This is CVE-2018-9251 and CVE-2018-14567.
15
16Thanks to Dongliang Mu and Simon Wรถrner for the reports.
17
18CVE: CVE-2018-9251
19CVE: CVE-2018-14567
20Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/libxml2/commit/2240fbf5912054af025fb6e01e26375100275e74]
21Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
22---
23 xzlib.c | 9 +++++++++
24 1 file changed, 9 insertions(+)
25
26diff --git a/xzlib.c b/xzlib.c
27index a839169..0ba88cf 100644
28--- a/xzlib.c
29+++ b/xzlib.c
30@@ -562,6 +562,10 @@ xz_decomp(xz_statep state)
31 "internal error: inflate stream corrupt");
32 return -1;
33 }
34+ /*
35+ * FIXME: Remapping a couple of error codes and falling through
36+ * to the LZMA error handling looks fragile.
37+ */
38 if (ret == Z_MEM_ERROR)
39 ret = LZMA_MEM_ERROR;
40 if (ret == Z_DATA_ERROR)
41@@ -587,6 +591,11 @@ xz_decomp(xz_statep state)
42 xz_error(state, LZMA_PROG_ERROR, "compression error");
43 return -1;
44 }
45+ if ((state->how != GZIP) &&
46+ (ret != LZMA_OK) && (ret != LZMA_STREAM_END)) {
47+ xz_error(state, ret, "lzma error");
48+ return -1;
49+ }
50 } while (strm->avail_out && ret != LZMA_STREAM_END);
51
52 /* update available output and crc check value */
53--
542.7.4
55