Blame SOURCES/LibVNCServer-0.9.9-CVE-2014-6052.patch

41da01
From 161a1d5c884f5d4c4be9522acbab8f16cb6fd7eb Mon Sep 17 00:00:00 2001
41da01
From: newsoft <newsoft@MacBook-Air-de-newsoft-2.local>
41da01
Date: Fri, 31 Oct 2014 12:46:28 +0100
41da01
Subject: [PATCH] Check for MallocFrameBuffer() return value
41da01
MIME-Version: 1.0
41da01
Content-Type: text/plain; charset=UTF-8
41da01
Content-Transfer-Encoding: 8bit
41da01
41da01
If MallocFrameBuffer() returns FALSE, frame buffer pointer is left to
41da01
NULL. Subsequent writes into that buffer could lead to memory
41da01
corruption, or even arbitrary code execution.
41da01
41da01
Signed-off-by: Petr Písař <ppisar@redhat.com>
41da01
---
41da01
 libvncclient/rfbproto.c  | 10 +++++++---
41da01
 libvncclient/vncviewer.c |  3 ++-
41da01
 2 files changed, 9 insertions(+), 4 deletions(-)
41da01
41da01
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c
41da01
index 3ecc011..beb87fc 100644
41da01
--- a/libvncclient/rfbproto.c
41da01
+++ b/libvncclient/rfbproto.c
41da01
@@ -1807,7 +1807,8 @@ HandleRFBServerMessage(rfbClient* client)
41da01
 	client->updateRect.x = client->updateRect.y = 0;
41da01
 	client->updateRect.w = client->width;
41da01
 	client->updateRect.h = client->height;
41da01
-	client->MallocFrameBuffer(client);
41da01
+  if (!client->MallocFrameBuffer(client))
41da01
+    return FALSE;
41da01
 	SendFramebufferUpdateRequest(client, 0, 0, rect.r.w, rect.r.h, FALSE);
41da01
 	rfbClientLog("Got new framebuffer size: %dx%d\n", rect.r.w, rect.r.h);
41da01
 	continue;
41da01
@@ -2260,7 +2261,8 @@ HandleRFBServerMessage(rfbClient* client)
41da01
     client->updateRect.x = client->updateRect.y = 0;
41da01
     client->updateRect.w = client->width;
41da01
     client->updateRect.h = client->height;
41da01
-    client->MallocFrameBuffer(client);
41da01
+    if (!client->MallocFrameBuffer(client))
41da01
+      return FALSE;
41da01
     SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);
41da01
     rfbClientLog("Got new framebuffer size: %dx%d\n", client->width, client->height);
41da01
     break;
41da01
@@ -2276,7 +2278,9 @@ HandleRFBServerMessage(rfbClient* client)
41da01
     client->updateRect.x = client->updateRect.y = 0;
41da01
     client->updateRect.w = client->width;
41da01
     client->updateRect.h = client->height;
41da01
-    client->MallocFrameBuffer(client);
41da01
+    if (!client->MallocFrameBuffer(client))
41da01
+      return FALSE;
41da01
+
41da01
     SendFramebufferUpdateRequest(client, 0, 0, client->width, client->height, FALSE);
41da01
     rfbClientLog("Got new framebuffer size: %dx%d\n", client->width, client->height);
41da01
     break;
41da01
diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c
41da01
index b2cce2b..978a9a7 100644
41da01
--- a/libvncclient/vncviewer.c
41da01
+++ b/libvncclient/vncviewer.c
41da01
@@ -243,7 +243,8 @@ static rfbBool rfbInitConnection(rfbClient* client)
41da01
 
41da01
   client->width=client->si.framebufferWidth;
41da01
   client->height=client->si.framebufferHeight;
41da01
-  client->MallocFrameBuffer(client);
41da01
+  if (!client->MallocFrameBuffer(client))
41da01
+    return FALSE;
41da01
 
41da01
   if (!SetFormatAndEncodings(client))
41da01
     return FALSE;
41da01
-- 
41da01
1.9.3
41da01