From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Toso <me@victortoso.com>
Date: Fri, 6 Apr 2018 09:59:44 +0200
Subject: [PATCH] channel-usbredir: Fix crash on channel-up
By adding a guard to not handle channel-up on SpiceUsbredirChannel in
case struct usbredirhost wasn't initialized yet. Same guard is in
place for the generic usbredir_handle_msg() function to avoid handling
Server's message while Client's initialization is not done.
As mentioned in commit 291f3e4419e6, this isn't a problem for
graphical clients as some initialization is done to present the
shareable usb devices to user.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1399838
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
---
src/channel-usbredir.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index 1f791bc..306bdd5 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -817,6 +817,7 @@ static void spice_usbredir_channel_up(SpiceChannel *c)
SpiceUsbredirChannel *channel = SPICE_USBREDIR_CHANNEL(c);
SpiceUsbredirChannelPrivate *priv = channel->priv;
+ g_return_if_fail(priv->host != NULL);
/* Flush any pending writes */
usbredirhost_write_guest_data(priv->host);
}