File CVE-2016-9578-remote-dos-via-crafted-message.patch of Package spice.4108

From fb8760d657271f52b357f83615c81bc984a3a197 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <fziglio@redhat.com>
Date: Mon, 28 Nov 2016 13:15:58 +0000
Subject: [PATCH spice-server] Prevent possible DoS attempts during protocol handshake

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/reds.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Index: spice-0.12.4/server/reds.c
===================================================================
--- spice-0.12.4.orig/server/reds.c	2017-02-02 14:27:32.543097049 +0100
+++ spice-0.12.4/server/reds.c	2017-02-02 14:28:07.929710382 +0100
@@ -2706,6 +2706,14 @@ static void reds_handle_read_link_done(v
         return;
     }
 
+    /* Prevent DoS. Currently we defined only 13 capabilities so here 1 would suffice,
+     * I expect 1024 to be valid for quite a lot time */
+    if (link_mess->num_channel_caps > 1024 || link_mess->num_common_caps > 1024) {
+        reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
+        reds_link_free(link);
+        return;
+    }
+
     auth_selection = test_capabilty(caps, link_mess->num_common_caps,
                                     SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
 
@@ -2780,7 +2788,8 @@ static void reds_handle_read_header_done
 
     reds->peer_minor_version = header->minor_version;
 
-    if (header->size < sizeof(SpiceLinkMess)) {
+    /* the check for 4096 is to avoid clients to attempt DoS to the server */
+    if (header->size < sizeof(SpiceLinkMess) || header->size > 4096) {
         reds_send_link_error(link, SPICE_LINK_ERR_INVALID_DATA);
         spice_warning("bad size %u", header->size);
         reds_link_free(link);
openSUSE Build Service is sponsored by