diff options
author | Antonio Quartulli | 2022-09-18 00:42:27 +0200 |
---|---|---|
committer | Gert Doering | 2022-09-18 12:54:55 +0200 |
commit | 5ac33a88b10584c3e52dc0c01dad2571b75be239 (patch) | |
tree | b5b4dd29682f0f3c57dfde63ff8a541893b7f296 /src | |
parent | 7de4be94e297ab1ea87ab17934f2026d7124239c (diff) | |
download | openvpn-5ac33a88b10584c3e52dc0c01dad2571b75be239.zip openvpn-5ac33a88b10584c3e52dc0c01dad2571b75be239.tar.gz |
delete_routes(_ipv6): avoid memleak if RT_DEFINED is not set
In this case the function would exit without releasing the argv object
initialized via argv_new().
Move initialization of argv after thic check is performed.
While at it, also move the declaration of gc and initizlize it with
gc_new().
Reported-by: Camille Guérin <guerincamille56@gmail.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220917224227.16988-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25245.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/openvpn/route.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 7eaf112..ded8fec 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -2145,8 +2145,6 @@ delete_route(struct route_ipv4 *r, const struct env_set *es, openvpn_net_ctx_t *ctx) { - struct gc_arena gc; - struct argv argv = argv_new(); #if !defined(TARGET_LINUX) const char *network; #if !defined(TARGET_AIX) @@ -2165,7 +2163,8 @@ delete_route(struct route_ipv4 *r, return; } - gc_init(&gc); + struct gc_arena gc = gc_new(); + struct argv argv = argv_new(); #if !defined(TARGET_LINUX) network = print_in_addr_t(r->network, 0, &gc); @@ -2336,8 +2335,6 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flags, const struct env_set *es, openvpn_net_ctx_t *ctx) { - struct gc_arena gc; - struct argv argv = argv_new(); const char *network; #if !defined(TARGET_LINUX) const char *gateway; @@ -2360,7 +2357,8 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt, } #endif - gc_init(&gc); + struct gc_arena gc = gc_new(); + struct argv argv = argv_new(); network = print_in6_addr( r6->network, 0, &gc); #if !defined(TARGET_LINUX) |