>
> Wraps the deserialization of the received messages in an InboundMessages
> class. The class is created with the deserialized header and the raw
> data of the message. A template function get_payload() returns the
> struct of the concrete message. The function is specialized for each
> incoming message.
>
> While this leaves the responsibility to call the get_payload() function
> with the message according to the type in the header to the caller, the
> solution preserves the efficiency of the original implementation without
> introducing too much complexity around the separation of the code.
>
> Signed-off-by: Lukáš Hrázký <[email protected]>
Rebasing I did this change:
@@ -31,6 +31,12 @@ StartStopMessage
InboundMessage::get_payload<StartStopMessage>()
msg.start_streaming = data[0]; // num_codecs
+ const int max_codecs = header.size - 1; /* see struct StreamMsgStartStop */
+ if (data[0] > max_codecs) {
+ throw std::runtime_error("num_codecs=" + std::to_string(data[0]) +
+ " > max_codecs=" +
std::to_string(max_codecs));
+ }
+
for (size_t i = 1; i <= data[0]; ++i) {
msg.client_codecs.insert((SpiceVideoCodecType) data[i]);
}
Frediano
_______________________________________________
Spice-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/spice-devel