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

Victor Toso victortoso at redhat.com
Thu Feb 26 05:13:11 PST 2015


Hey,

On Thu, Feb 26, 2015 at 08:07:18AM -0500, Marc-André Lureau wrote:
> Hi
>
> ----- Original Message -----
> > 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'
>
> I wonder if this shouldn't be acceptable URI, I think it could be.

So it the fix should be in the spice_parse_uri then?

> > As we already check if port and tls_port are NULL, I've changed the
> > check to verify if it is an empty string.
>
> g_return_val_if_fail(s->port != NULL || s->tls_port != NULL, NULL);
>
> We check if one of the two is !NULL, so you still need to keep a NULL check

oops, my bad. Thanks!

> > ---
> >  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
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
> > 


More information about the Spice-devel mailing list