Blame SOURCES/0004-matroskademux-Avoid-integer-overflow-resulting-in-he.patch

27715b
From c0ac3357342599cc09397c6af0e696770ae94548 Mon Sep 17 00:00:00 2001
27715b
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
27715b
Date: Wed, 18 May 2022 10:23:15 +0300
27715b
Subject: [PATCH 4/4] matroskademux: Avoid integer-overflow resulting in heap
27715b
 corruption in WavPack header handling code
27715b
27715b
blocksize + WAVPACK4_HEADER_SIZE might overflow gsize, which then
27715b
results in allocating a very small buffer. Into that buffer blocksize
27715b
data is memcpy'd later which then causes out of bound writes and can
27715b
potentially lead to anything from crashes to remote code execution.
27715b
27715b
Thanks to Adam Doupe for analyzing and reporting the issue.
27715b
27715b
CVE: CVE-2022-1920
27715b
27715b
https://gstreamer.freedesktop.org/security/sa-2022-0004.html
27715b
27715b
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1226
27715b
27715b
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2612>
27715b
---
27715b
 gst/matroska/matroska-demux.c | 10 +++++++++-
27715b
 1 file changed, 9 insertions(+), 1 deletion(-)
27715b
27715b
diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
27715b
index 0e47ee7b5e..b7d009de90 100644
27715b
--- a/gst/matroska/matroska-demux.c
27715b
+++ b/gst/matroska/matroska-demux.c
27715b
@@ -3893,7 +3893,8 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
27715b
   } else {
27715b
     guint8 *outdata = NULL;
27715b
     gsize buf_size, size;
27715b
-    guint32 block_samples, flags, crc, blocksize;
27715b
+    guint32 block_samples, flags, crc;
27715b
+    gsize blocksize;
27715b
     GstAdapter *adapter;
27715b
 
27715b
     adapter = gst_adapter_new ();
27715b
@@ -3934,6 +3935,13 @@ gst_matroska_demux_add_wvpk_header (GstElement * element,
27715b
         return GST_FLOW_ERROR;
27715b
       }
27715b
 
27715b
+      if (blocksize > G_MAXSIZE - WAVPACK4_HEADER_SIZE) {
27715b
+        GST_ERROR_OBJECT (element, "Too big wavpack buffer");
27715b
+        gst_buffer_unmap (*buf, &map);
27715b
+        g_object_unref (adapter);
27715b
+        return GST_FLOW_ERROR;
27715b
+      }
27715b
+
27715b
       g_assert (newbuf == NULL);
27715b
 
27715b
       newbuf =
27715b
-- 
27715b
2.38.1
27715b