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

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