net: Fix parse_url().
authorAndre Noll <maan@systemlinux.org>
Fri, 6 Sep 2013 22:36:36 +0000 (22:36 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 22 Dec 2013 16:39:20 +0000 (16:39 +0000)
Does not correctly parse host, if given array has no extra
space.

net.c

diff --git a/net.c b/net.c
index e9b5ed1c0607a327f8dcbb2fbf74ac9c0ed30bf0..caf84c90f0680538140bc77b840befb2ec8cd9c8 100644 (file)
--- a/net.c
+++ b/net.c
@@ -168,16 +168,16 @@ char *parse_url(const char *url,
                if (*o++ != ']' || (*o != '\0' && *o != ':'))
                        goto failed;
        } else {
                if (*o++ != ']' || (*o != '\0' && *o != ':'))
                        goto failed;
        } else {
-               for (; (*c = *o == ':'? '\0' : *o); c++, o++)
-                       if (c == end)
+               for (; (*c = *o == ':'? '\0' : *o); c++, o++) {
+                       if (c == end && o[1])
                                goto failed;
                                goto failed;
+               }
        }
 
        if (*o == ':')
                if (para_atoi32(++o, port) < 0 ||
                    *port < 0 || *port > 0xffff)
                        goto failed;
        }
 
        if (*o == ':')
                if (para_atoi32(++o, port) < 0 ||
                    *port < 0 || *port > 0xffff)
                        goto failed;
-
        if (host_string_ok(host))
                return host;
 failed:
        if (host_string_ok(host))
                return host;
 failed: