[Spice-devel] [PATCH] session: do not set empty port value from uri

Victor Toso victortoso at redhat.com
Thu Feb 26 05:02:55 PST 2015


Setting an empty port value from URI makes spicy unable to connect from
'Recent connections' due a break URI given by spice_uri_create:

e.g: localhost?port=5900&tls-port=

Trying to connect with above URI breaks at spice_parse_uri with
'Failed to parse URI query'

As we already check if port and tls_port are NULL, I've changed the
check to verify if it is an empty string.
---
 gtk/spice-session.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gtk/spice-session.c b/gtk/spice-session.c
index 82ea55f..28ee8bc 100644
--- a/gtk/spice-session.c
+++ b/gtk/spice-session.c
@@ -366,12 +366,13 @@ static gchar* spice_uri_create(SpiceSession *session)
 
         g_string_append(str, s->host);
         g_string_append(str, "?");
-        if (s->port != NULL) {
+        if (s->port[0] != '\0') {
             g_string_append_printf(str, "port=%s&", s->port);
         }
-        if (s->tls_port != NULL) {
+        if (s->tls_port[0] != '\0') {
             g_string_append_printf(str, "tls-port=%s", s->tls_port);
         }
+
         return g_string_free(str, FALSE);
     }
 
-- 
2.1.0



More information about the Spice-devel mailing list