Blame SOURCES/CVE-2018-8787.patch

0c73ee
diff --git a/libfreerdp-gdi/graphics.c b/libfreerdp-gdi/graphics.c
0c73ee
index 04816334c..5a49bd365 100644
0c73ee
--- a/libfreerdp-gdi/graphics.c
0c73ee
+++ b/libfreerdp-gdi/graphics.c
0c73ee
@@ -30,6 +30,8 @@
0c73ee
 #include <freerdp/codec/bitmap.h>
0c73ee
 #include <freerdp/cache/glyph.h>
0c73ee
 
0c73ee
+#include <stdint.h>
0c73ee
+
0c73ee
 #include "graphics.h"
0c73ee
 
0c73ee
 /* Bitmap Class */
0c73ee
@@ -89,9 +91,18 @@ void gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
0c73ee
 void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
0c73ee
 		uint8* data, int width, int height, int bpp, int length, boolean compressed)
0c73ee
 {
0c73ee
-	uint16 size;
0c73ee
+	uint32 size = width * height;
0c73ee
+	int bpp_op = (bpp + 7) / 8;
0c73ee
+
0c73ee
+	if ((bpp == 0) ||
0c73ee
+	    (width == 0) || (height == 0) || (width > UINT32_MAX / height) ||
0c73ee
+	    (size > (UINT32_MAX / bpp_op)))
0c73ee
+	{
0c73ee
+		printf("gdi_Bitmap_Decompress failed\n");
0c73ee
+		abort();
0c73ee
+	}
0c73ee
 
0c73ee
-	size = width * height * (bpp + 7) / 8;
0c73ee
+	size *= bpp_op;
0c73ee
 
0c73ee
 	if (bitmap->data == NULL)
0c73ee
 		bitmap->data = (uint8*) xmalloc(size);