]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Fix memory leak in pulse.c
authorDaniel Lenski <dlenski@gmail.com>
Mon, 7 Feb 2022 02:01:41 +0000 (18:01 -0800)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 7 Feb 2022 02:01:41 +0000 (18:01 -0800)
This issue was hidden by the oversight of Legacy IPv4 split routes in
3d845bc9b, which was subsequently fixed in
https://gitlab.com/openconnect/openconnect/-/merge_requests/330 / 52d1c674.

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

diff --git a/pulse.c b/pulse.c
index d0e2fec06d95da49680ba93669fb9eacc7b89e74..0d7fca192e37b81e5553c45bb5f59932b13e20f8 100644 (file)
--- a/pulse.c
+++ b/pulse.c
@@ -2259,6 +2259,9 @@ static int handle_main_config_packet(struct openconnect_info *vpninfo,
        int l;
        unsigned char *p;
 
+       struct oc_vpn_option *new_opts = NULL;
+       struct oc_ip_info new_ip_info = {};
+
        /* First part of header, similar to ESP, has already been checked */
        if (len < 0x31 ||
            /* Start of routing information */
@@ -2273,14 +2276,13 @@ static int handle_main_config_packet(struct openconnect_info *vpninfo,
                vpn_progress(vpninfo, PRG_ERR,
                             _("Unexpected Pulse config packet:\n"));
                dump_buf_hex(vpninfo, PRG_ERR, '<', (void *)bytes, len);
+               free_optlist(new_opts);
+               free_split_routes(&new_ip_info);
                return -EINVAL;
        }
        p = bytes + 0x34;
        routes_len -= 8; /* The header including length and number of routes */
 
-       struct oc_vpn_option *new_opts = NULL;
-       struct oc_ip_info new_ip_info = {};
-
        /* We know it's a multiple of 0x10 now. We checked. */
        while (routes_len) {
                char buf[80];