]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix proxy username and password parsing.
authorDavid Woodhouse <dwmw2@infradead.org>
Fri, 2 Aug 2019 21:05:08 +0000 (14:05 -0700)
committerDavid Woodhouse <dwmw2@infradead.org>
Fri, 2 Aug 2019 21:09:01 +0000 (14:09 -0700)
We are supposed to take the *last* (unescaped) @ sign as the separation
between user:pass and hostname, not the first. So use strrchr() instead
of strchr().

Conversely, the first colon is the separation between user and pass so
strchr is still correct there.

Also actually support unescaping the resulting username and password.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
http.c
www/changelog.xml

diff --git a/http.c b/http.c
index 36995e128e934625b8ae5279cb1cf87034a02666..bd531abce0f9672740e04e6e28ee553d09a6a255 100644 (file)
--- a/http.c
+++ b/http.c
@@ -28,6 +28,8 @@
 #include <stdio.h>
 #include <stdarg.h>
 
+#include <libxml/uri.h>
+
 #include "openconnect-internal.h"
 
 static int proxy_write(struct openconnect_info *vpninfo, char *buf, size_t len);
@@ -1383,7 +1385,7 @@ int openconnect_set_http_proxy(struct openconnect_info *vpninfo,
        if (ret)
                goto out;
 
-       p = strchr(vpninfo->proxy, '@');
+       p = strrchr(vpninfo->proxy, '@');
        if (p) {
                /* Proxy username/password */
                *p = 0;
@@ -1393,7 +1395,9 @@ int openconnect_set_http_proxy(struct openconnect_info *vpninfo,
                if (p) {
                        *p = 0;
                        vpninfo->proxy_pass = strdup(p + 1);
+                       xmlURIUnescapeString(vpninfo->proxy_pass, 0, vpninfo->proxy_pass);
                }
+               xmlURIUnescapeString(vpninfo->proxy_user, 0, vpninfo->proxy_user);
        }
 
        if (vpninfo->proxy_type &&
index 70436d278b9fd929e5a8b38bd26b0aea90530bed..0c39151202665639e93be8b2edd3890b608e6797 100644 (file)
@@ -21,6 +21,7 @@
        <li>Add HMAC-SHA256-128 (RFC4868) support for ESP.</li>
        <li>Support IPv6 in ESP.</li>
        <li>Translate user-visible strings from <tt>openconnect_get_supported_protocols()</tt>.</li>
+       <li>Fix proxy username/password handling to allow special characters and escaping.</li>
      </ul><br/>
   </li>
   <li><b><a href="ftp://ftp.infradead.org/pub/openconnect/openconnect-8.03.tar.gz">OpenConnect v8.03</a></b>