Blame SOURCES/0003-qtdemux-Fix-integer-overflows-in-zlib-decompression-.patch

27715b
From 24267889a717e1e799037a0f1841d5416eb56e75 Mon Sep 17 00:00:00 2001
27715b
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
27715b
Date: Mon, 30 May 2022 10:15:37 +0300
27715b
Subject: [PATCH 3/4] qtdemux: Fix integer overflows in zlib decompression code
27715b
27715b
Various variables were of smaller types than needed and there were no
27715b
checks for any overflows when doing additions on the sizes. This is all
27715b
checked now.
27715b
27715b
In addition the size of the decompressed data is limited to 200MB now as
27715b
any larger sizes are likely pathological and we can avoid out of memory
27715b
situations in many cases like this.
27715b
27715b
Also fix a bug where the available output size on the next iteration in
27715b
the zlib decompression code was provided too large and could
27715b
potentially lead to out of bound writes.
27715b
27715b
Thanks to Adam Doupe for analyzing and reporting the issue.
27715b
27715b
CVE: tbd
27715b
27715b
https://gstreamer.freedesktop.org/security/sa-2022-0003.html
27715b
27715b
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1225
27715b
27715b
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2610>
27715b
---
27715b
 gst/isomp4/qtdemux.c | 8 +++++++-
27715b
 1 file changed, 7 insertions(+), 1 deletion(-)
27715b
27715b
diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
27715b
index 182d0bc06f..a9cbbd4cd3 100644
27715b
--- a/gst/isomp4/qtdemux.c
27715b
+++ b/gst/isomp4/qtdemux.c
27715b
@@ -7611,10 +7611,16 @@ qtdemux_inflate (void *z_buffer, guint z_length, guint * length)
27715b
       break;
27715b
     }
27715b
 
27715b
+    if (*length > G_MAXUINT - 4096 || *length > QTDEMUX_MAX_SAMPLE_INDEX_SIZE) {
27715b
+      GST_WARNING ("too big decompressed data");
27715b
+      ret = Z_MEM_ERROR;
27715b
+      break;
27715b
+    }
27715b
+
27715b
     *length += 4096;
27715b
     buffer = (guint8 *) g_realloc (buffer, *length);
27715b
     z.next_out = (Bytef *) (buffer + z.total_out);
27715b
-    z.avail_out += 4096;
27715b
+    z.avail_out += *length - z.total_out;
27715b
   } while (z.avail_in > 0);
27715b
 
27715b
   if (ret != Z_STREAM_END) {
27715b
-- 
27715b
2.38.1
27715b