]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
F5: fix old options leak on reconnect
authorDaniel Lenski <dlenski@gmail.com>
Mon, 8 Feb 2021 21:38:40 +0000 (13:38 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 29 Mar 2021 03:13:30 +0000 (20:13 -0700)
Need to save in cstp_options, but also strdup() because
process_http_response() will clobber them if we don't

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
f5.c

diff --git a/f5.c b/f5.c
index ed7ce8242e0e33fbaa5285dcce0427a2d347a23f..e2210fe176d198b5a177265895b217a0f94743c3 100644 (file)
--- a/f5.c
+++ b/f5.c
@@ -389,22 +389,21 @@ static int parse_options(struct openconnect_info *vpninfo, char *buf, int len,
 }
 
 static int get_ip_address(struct openconnect_info *vpninfo, char *header, char *val) {
-       char *s;
+       char *s = strdup(val);
        if (!strcasecmp(header, "X-VPN-client-IP")) {
                vpn_progress(vpninfo, PRG_INFO,
                             _("Got legacy IP address %s\n"), val);
-               vpninfo->ip_info.addr = s = strdup(val);
-               if (!s) return -ENOMEM;
+               vpninfo->ip_info.addr = add_option(vpninfo, "ipaddr", &s);
        } else if (!strcasecmp(header, "X-VPN-client-IPv6")) {
                vpn_progress(vpninfo, PRG_INFO,
                             _("Got IPv6 address %s\n"), val);
                /* XX: Should we treat this as a /64 netmask? Or an /128 address? */
-               vpninfo->ip_info.addr6 = s = strdup(val);
-               if (!s) return -ENOMEM;
+               vpninfo->ip_info.addr6 = add_option(vpninfo, "ipaddr6", &s);
        }
         /* XX: The server's IP address(es) X-VPN-server-{IP,IPv6} are also
          * sent, but the utility of these is unclear. As remarked in oncp.c,
         * "this is a tunnel; having a gateway is meaningless." */
+       free(s);
        return 0;
 }
 
@@ -417,6 +416,7 @@ int f5_connect(struct openconnect_info *vpninfo)
        char *sid = NULL, *ur_z = NULL;
        int ipv4 = -1, ipv6 = -1, hdlc = -1;
        char *res_buf = NULL;
+       struct oc_vpn_option *old_cstp_opts = vpninfo->cstp_options;
        const char *old_addr = vpninfo->ip_info.addr;
        const char *old_netmask = vpninfo->ip_info.netmask;
        const char *old_addr6 = vpninfo->ip_info.addr6;
@@ -523,6 +523,7 @@ int f5_connect(struct openconnect_info *vpninfo)
        ret = openconnect_ppp_new(vpninfo, hdlc ? PPP_ENCAP_F5_HDLC : PPP_ENCAP_F5, ipv4, ipv6);
 
  out:
+       free_optlist(old_cstp_opts);
        free(res_buf);
        free(profile_params);
        free(sid);