From 818e44b5dfc9d9795fcde25bd26b76b1297093d3 Mon Sep 17 00:00:00 2001 From: Frediano Ziglio Date: Wed, 13 Feb 2019 14:46:16 +0000 Subject: [PATCH] reds: Check QXL ID registering interface Avoid to register multiple interface with the same ID. This would result in issues as 2 channels would have the same (channel_type, channel_id) which must be unique. Qemu always allocates QXL interface with IDs starting from 0. Signed-off-by: Frediano Ziglio Acked-by: Christophe Fergeau --- server/reds.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/reds.c b/server/reds.c index fbc21f7b..2e5c69e6 100644 --- a/server/reds.c +++ b/server/reds.c @@ -3378,6 +3378,14 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *reds, } qxl = SPICE_UPCAST(QXLInstance, sin); + if (qxl->id < 0) { + spice_warning("invalid QXL ID"); + return -1; + } + if (reds_find_channel(reds, SPICE_CHANNEL_DISPLAY, qxl->id)) { + spice_warning("QXL ID already allocated"); + return -1; + } red_qxl_init(reds, qxl); reds->qxl_instances = g_list_prepend(reds->qxl_instances, qxl);