Fix corruption of input string to openconnect_parse_url()
authorDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 13 May 2012 03:49:39 +0000 (20:49 -0700)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 13 May 2012 03:49:39 +0000 (20:49 -0700)
Well, kind of. This is the approach which was partially implemented in
commit 382d05dd1929788be151e96d80e7b8289b8f7c08 but missed restoring the
colon before the port number. It's still fairly dodgy that we're scribbling
on the input string at all, even if we do put it back again afterwards.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
http.c

diff --git a/http.c b/http.c
index ef13360..188b76a 100644 (file)
--- a/http.c
+++ b/http.c
@@ -613,6 +613,8 @@ int internal_parse_url(char *url, char **res_proto, char **res_host,
                *res_path = (path && *path) ? strdup(path) : NULL;
 
        /* Undo the damage we did to the original string */
+       if (port_str)
+               *(port_str) = ':';
        if (path)
                *(path - 1) = '/';
        if (proto)