[Spice-devel] [PATCH spice-gtk] session: warn on invalid port value
Marc-André Lureau
marcandre.lureau at gmail.com
Wed Feb 20 08:58:48 PST 2013
---
gtk/spice-session.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index ccc9367..88ab5f6 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -1745,15 +1745,22 @@ GSocket* spice_session_channel_open_host(SpiceSession *session, SpiceChannel *ch
{
SpiceSessionPrivate *s = SPICE_SESSION_GET_PRIVATE(session);
spice_open_host open_host = { 0, };
-
- if ((use_tls && !s->tls_port) || (!use_tls && !s->port))
- return NULL;
+ gchar *port, *endptr;
// FIXME: make open_host() cancellable
open_host.from = coroutine_self();
open_host.session = session;
open_host.channel = channel;
- open_host.port = atoi(use_tls ? s->tls_port : s->port);
+ port = use_tls ? s->tls_port : s->port;
+ if (port == NULL)
+ return NULL;
+
+ open_host.port = strtol(port, &endptr, 10);
+ if (*port == '\0' || *endptr != '\0') {
+ g_warning("Invalid port value %s", port);
+ return NULL;
+ }
+
open_host.client = g_socket_client_new();
guint id = g_idle_add(open_host_idle_cb, &open_host);
--
1.8.1.1.439.g50a6b54
More information about the Spice-devel
mailing list