[Spice-devel] [PATCH spice-gtk v3 5/7] spice-uri: Do not allow empty port string
Pavel Grunt
pgrunt at redhat.com
Fri May 20 09:09:43 UTC 2016
On Fri, 2016-05-20 at 10:32 +0200, Victor Toso wrote:
> Hi,
>
> On Thu, May 19, 2016 at 06:38:07PM +0200, Pavel Grunt wrote:
> > Related: rhbz#1335239
> > ---
> > src/spice-uri.c | 3 +++
> > tests/test-spice-uri.c | 1 +
> > 2 files changed, 4 insertions(+)
> >
> > diff --git a/src/spice-uri.c b/src/spice-uri.c
> > index 04ea3cb..b483374 100644
> > --- a/src/spice-uri.c
> > +++ b/src/spice-uri.c
> > @@ -171,6 +171,9 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar
> > *_uri, GError **error)
> > g_set_error(error, SPICE_CLIENT_ERROR,
> > SPICE_CLIENT_ERROR_FAILED,
> > "Invalid uri port: %s", uri_port);
> > goto end;
> > + } else if (endptr == uri_port) {
> > + g_set_error(error, SPICE_CLIENT_ERROR,
> > SPICE_CLIENT_ERROR_FAILED, "Missing uri port");
> > + goto end;
>
> You might want to use/include the return value of strtoul for zero in this
> case
I would not change the value, parsing failed so SpiceURI should not be consider
valid
Pavel
>
> Acked-by: Victor Toso <victortoso at redhat.com>
>
> > }
> > spice_uri_set_port(self, port);
> > }
> > diff --git a/tests/test-spice-uri.c b/tests/test-spice-uri.c
> > index 1b14dbb..42c9aad 100644
> > --- a/tests/test-spice-uri.c
> > +++ b/tests/test-spice-uri.c
> > @@ -34,6 +34,7 @@ static void test_spice_uri_ipv4(void)
> > {"http://:80", "http", NULL, 80, NULL, NULL}, /* missing hostname
> > */
> > {"http://", "http", NULL, 3128, NULL, NULL},
> > {"http://127.0.0.1:port", "http", "127.0.0.1", 3128, NULL, NULL},
> > /* invalid port */
> > + {"http://127.0.0.1:", "http", "127.0.0.1", 3128, NULL, NULL},
> > };
> > const struct test_case valid_test_cases[] = {
> > {"http://user:password@host:80", "http", "host", 80, "user",
> > "password"},
> > --
> > 2.8.2
> >
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list