summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2017-09-11 09:48:10 +0100
committerFrediano Ziglio <fziglio@redhat.com>2017-09-12 08:54:39 +0100
commit1c83deea989e3cccb927a164b80ef81d55b02180 (patch)
tree348aafd8413888809938806ae73a077de3aa5810
parentb84d5d0124fcf1719007539ac49c1ce3b6c0cf75 (diff)
red-channel-client: Early check for valid stream
The code tests for the presence of RedChannelClient::stream while initializing RedChannelClient. However, the check was done too late, and a RedChannelClient::config_socket implementation (for example snd_channel_client_config_socket) could have tried to use it before the check that it's not NULL. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Christophe Fergeau <cfergeau@redhat.com>
-rw-r--r--server/red-channel-client.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 9a47b7e6..34202c49 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -922,6 +922,14 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
SpiceCoreInterfaceInternal *core;
RedChannelClient *self = RED_CHANNEL_CLIENT(initable);
+ if (!self->priv->stream) {
+ g_set_error_literal(&local_error,
+ SPICE_SERVER_ERROR,
+ SPICE_SERVER_ERROR_FAILED,
+ "Socket not available");
+ goto cleanup;
+ }
+
if (!red_channel_client_config_socket(self)) {
g_set_error_literal(&local_error,
SPICE_SERVER_ERROR,
@@ -931,14 +939,12 @@ static gboolean red_channel_client_initable_init(GInitable *initable,
}
core = red_channel_get_core_interface(self->priv->channel);
- if (self->priv->stream) {
- reds_stream_set_core_interface(self->priv->stream, core);
- self->priv->stream->watch =
- core->watch_add(core, self->priv->stream->socket,
- SPICE_WATCH_EVENT_READ,
- red_channel_client_event,
- self);
- }
+ reds_stream_set_core_interface(self->priv->stream, core);
+ self->priv->stream->watch =
+ core->watch_add(core, self->priv->stream->socket,
+ SPICE_WATCH_EVENT_READ,
+ red_channel_client_event,
+ self);
if (self->priv->monitor_latency
&& reds_stream_get_family(self->priv->stream) != AF_UNIX) {