From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
Date: Thu, 26 Sep 2024 22:16:06 +0300
Subject: qtdemux: Avoid integer overflow when parsing Theora extension
Origin: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/2d7a11f5e6be5c323b2fed8158bc9df37752e495
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2024-47606

Thanks to Antonio Morales for finding and reporting the issue.

Fixes GHSL-2024-166
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3851

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8044>
---
 subprojects/gst-plugins-good/gst/isomp4/qtdemux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/gst/isomp4/qtdemux.c
+++ b/gst/isomp4/qtdemux.c
@@ -8172,7 +8172,7 @@ qtdemux_parse_theora_extension (GstQTDem
   end -= 8;
 
   while (buf < end) {
-    gint size;
+    guint32 size;
     guint32 type;
 
     size = QT_UINT32 (buf);
@@ -8180,7 +8180,7 @@ qtdemux_parse_theora_extension (GstQTDem
 
     GST_LOG_OBJECT (qtdemux, "%p %p", buf, end);
 
-    if (buf + size > end || size <= 0)
+    if (end - buf < size || size < 8)
       break;
 
     buf += 8;
