Blame SOURCES/0001-start-streaming-check-num_codecs.patch

647200
From 5aaaa5bd91261a6b61fcaa75585f8446b9eeb036 Mon Sep 17 00:00:00 2001
647200
From: Uri Lublin <uril@redhat.com>
647200
Date: Tue, 31 Jul 2018 16:18:15 +0300
647200
Subject: [PATCH 1/4] start streaming: check num_codecs
647200
647200
The server sends StreamMsgStartStop to tell spice-streaming-agent
647200
to start streaming and a list of available codecs.
647200
647200
The first uint8_t is the number of codecs.
647200
Each following uint8_t is a codec.
647200
647200
This patch checks that the number of codecs in the message, as
647200
reported by the server, is not too large.
647200
---
647200
 src/spice-streaming-agent.cpp | 5 +++++
647200
 1 file changed, 5 insertions(+)
647200
647200
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
647200
index 1121f35..9ebbf5d 100644
647200
--- a/src/spice-streaming-agent.cpp
647200
+++ b/src/spice-streaming-agent.cpp
647200
@@ -95,6 +95,11 @@ static void handle_stream_start_stop(StreamPort &stream_port, uint32_t len)
647200
     syslog(LOG_INFO, "GOT START_STOP message -- request to %s streaming\n",
647200
            streaming_requested ? "START" : "STOP");
647200
     client_codecs.clear();
647200
+    const int mnc = len - 1; /* max num codecs, see struct StreamMsgStartStop */
647200
+    if (msg[0] > mnc) {
647200
+        throw std::runtime_error("num_codecs=" + std::to_string(msg[0]) +
647200
+                                 " > max_num_codecs=" + std::to_string(mnc));
647200
+    }
647200
     for (int i = 1; i <= msg[0]; ++i) {
647200
         client_codecs.insert((SpiceVideoCodecType) msg[i]);
647200
     }
647200
-- 
647200
2.17.1
647200