Blame SOURCES/0001-vmncdec-Sanity-check-width-height-before-using-it.patch

8b2abe
From 26f4b2c203d6d0ef0c8204a48dba504870c2cfdf Mon Sep 17 00:00:00 2001
8b2abe
From: Wim Taymans <wtaymans@redhat.com>
8b2abe
Date: Tue, 6 Dec 2016 10:24:03 +0100
8b2abe
Subject: [PATCH] vmncdec: Sanity-check width/height before using it
8b2abe
8b2abe
We will allocate a screen area of width*height*bpp bytes, however this
8b2abe
calculation can easily overflow if too high width or height are given
8b2abe
inside the stream. Nonetheless we would just assume that enough memory
8b2abe
was allocated, try to fill it and overwrite as much memory as wanted.
8b2abe
8b2abe
Also allocate the screen area filled with zeroes to ensure that we start
8b2abe
with full-black and not any random (or not so random) data.
8b2abe
8b2abe
https://scarybeastsecurity.blogspot.gr/2016/11/0day-poc-risky-design-decisions-in.html
8b2abe
8b2abe
Ideally we should just remove this plugin in favour of the one in
8b2abe
gst-libav, which generally seems to be of better code quality.
8b2abe
8b2abe
https://bugzilla.gnome.org/show_bug.cgi?id=774533
8b2abe
---
8b2abe
 gst/vmnc/vmncdec.c | 6 +++++-
8b2abe
 1 file changed, 5 insertions(+), 1 deletion(-)
8b2abe
8b2abe
diff --git a/gst/vmnc/vmncdec.c b/gst/vmnc/vmncdec.c
8b2abe
index 08085b5..c83e315 100644
8b2abe
--- a/gst/vmnc/vmncdec.c
8b2abe
+++ b/gst/vmnc/vmncdec.c
8b2abe
@@ -370,7 +370,7 @@ vmnc_handle_wmvi_rectangle (GstVMncDec * dec, struct RfbRectangle *rect,
8b2abe
 
8b2abe
   if (dec->imagedata)
8b2abe
     g_free (dec->imagedata);
8b2abe
-  dec->imagedata = g_malloc (dec->format.width * dec->format.height *
8b2abe
+  dec->imagedata = g_malloc0 (dec->format.width * dec->format.height *
8b2abe
       dec->format.bytes_per_pixel);
8b2abe
   GST_DEBUG_OBJECT (dec, "Allocated image data at %p", dec->imagedata);
8b2abe
 
8b2abe
@@ -901,6 +901,10 @@ vmnc_handle_packet (GstVMncDec * dec, const guint8 * data, int len,
8b2abe
             GST_WARNING_OBJECT (dec, "Rectangle out of range, type %d", r.type);
8b2abe
             return ERROR_INVALID;
8b2abe
           }
8b2abe
+        } else if (r.width > 16384 || r.height > 16384) {
8b2abe
+          GST_WARNING_OBJECT (dec, "Width or height too high: %ux%u", r.width,
8b2abe
+              r.height);
8b2abe
+          return ERROR_INVALID;
8b2abe
         }
8b2abe
 
8b2abe
         switch (r.type) {
8b2abe
-- 
8b2abe
2.9.3
8b2abe