Blame SOURCES/libxml2-CVE-2018-9251.patch

026269
From 2240fbf5912054af025fb6e01e26375100275e74 Mon Sep 17 00:00:00 2001
026269
From: Nick Wellnhofer <wellnhofer@aevum.de>
026269
Date: Mon, 30 Jul 2018 13:14:11 +0200
026269
Subject: [PATCH] Fix infinite loop in LZMA decompression
026269
MIME-Version: 1.0
026269
Content-Type: text/plain; charset=UTF-8
026269
Content-Transfer-Encoding: 8bit
026269
026269
Check the liblzma error code more thoroughly to avoid infinite loops.
026269
026269
Closes: https://gitlab.gnome.org/GNOME/libxml2/issues/13
026269
Closes: https://bugzilla.gnome.org/show_bug.cgi?id=794914
026269
026269
This is CVE-2018-9251 and CVE-2018-14567.
026269
026269
Thanks to Dongliang Mu and Simon Wörner for the reports.
026269
---
026269
 xzlib.c | 9 +++++++++
026269
 1 file changed, 9 insertions(+)
026269
026269
diff --git a/xzlib.c b/xzlib.c
026269
index a839169e..0ba88cfa 100644
026269
--- a/xzlib.c
026269
+++ b/xzlib.c
026269
@@ -562,6 +562,10 @@ xz_decomp(xz_statep state)
026269
                          "internal error: inflate stream corrupt");
026269
                 return -1;
026269
             }
026269
+            /*
026269
+             * FIXME: Remapping a couple of error codes and falling through
026269
+             * to the LZMA error handling looks fragile.
026269
+             */
026269
             if (ret == Z_MEM_ERROR)
026269
                 ret = LZMA_MEM_ERROR;
026269
             if (ret == Z_DATA_ERROR)
026269
@@ -587,6 +591,11 @@ xz_decomp(xz_statep state)
026269
             xz_error(state, LZMA_PROG_ERROR, "compression error");
026269
             return -1;
026269
         }
026269
+        if ((state->how != GZIP) &&
026269
+            (ret != LZMA_OK) && (ret != LZMA_STREAM_END)) {
026269
+            xz_error(state, ret, "lzma error");
026269
+            return -1;
026269
+        }
026269
     } while (strm->avail_out && ret != LZMA_STREAM_END);
026269
 
026269
     /* update available output and crc check value */
026269
-- 
026269
2.22.0
026269