Hi, On 02/20/2013 05:58 PM, Marc-André Lureau wrote:
--- 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; + } +
If you're going to do this you should probably also check for open_host.port < 0 || open_host.port > 65535 Regards, Hans _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel