File CVE-2016-9577-buffer-overflow-in-main_channel_alloc_msg_rcv_buf.patch of Package spice

From 9f3ac8195f55027c6fb880d811141ae87d6d04f1 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Tue, 29 Nov 2016 16:46:56 +0000
Subject: [PATCH spice-server] main-channel: Prevent overflow reading messages from client

Caller is supposed the function return a buffer able to store
size bytes.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/main-channel.c | 3 +++
 1 file changed, 3 insertions(+)

Index: spice-0.12.7/server/main_channel.c
===================================================================
--- spice-0.12.7.orig/server/main_channel.c	2016-04-12 15:06:48.000000000 +0200
+++ spice-0.12.7/server/main_channel.c	2017-02-02 12:21:06.338289992 +0100
@@ -1026,6 +1026,9 @@ static uint8_t *main_channel_alloc_msg_r
 
     if (type == SPICE_MSGC_MAIN_AGENT_DATA) {
         return reds_get_agent_data_buffer(mcc, size);
+    } else if (size > sizeof(main_chan->recv_buf)) {
+        /* message too large, caller will log a message and close the connection */
+        return NULL;
     } else {
         return main_chan->recv_buf;
     }
openSUSE Build Service is sponsored by