[Spice-commits] server/red-channel-client.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Tue Sep 12 07:56:17 UTC 2017
server/red-channel-client.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
New commits:
commit 1c83deea989e3cccb927a164b80ef81d55b02180
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Mon Sep 11 09:48:10 2017 +0100
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 at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
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) {
More information about the Spice-commits
mailing list