[Openvpn-devel,2/2] Fix memory leaks in dco open tun

Message ID 20230314144854.182110-2-arne@rfc2549.org
State Accepted
Headers show
Series [Openvpn-devel,1/2] Fix memory leaks in HMAC initial packet id | expand

Commit Message

Arne Schwabe March 14, 2023, 2:48 p.m. UTC
The open_tun_dco_generic already allocates the actual_name string, this
shadows the allocation in the FreeBSD/Linux specific methods.

Found-By: clang with asan
Change-Id: I51f5fcfff4e5f8203fdb9aec0245cfccd17043cc
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
 src/openvpn/dco_freebsd.c | 1 -
 src/openvpn/dco_linux.c   | 1 -
 2 files changed, 2 deletions(-)


Gert Doering March 14, 2023, 3:03 p.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

This one is fairly straightforward (and the leak is small) - I've
re-read all the code involved for v2 of the patch (set) and the
change is correct.  The device name involved stays unchanged in
the current iterations of open_tun_dco(), so there is no need to
save it there (fallout of the many rewrites of these parts).

Your patch has been applied to the master and release/2.6 branch.

commit 021952705ba4b77a1d94bec85f6f02e6c612a37e (master)
commit be7a5640fbce2d3d56bdcee23e3d76ea15a678d1 (release/2.6)
Author: Arne Schwabe
Date:   Tue Mar 14 15:48:54 2023 +0100

     Fix memory leaks in dco open tun

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20230314144854.182110-2-arne@rfc2549.org>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26411.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>

kind regards,

Gert Doering


diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c
index ecca2a076..225b3cf88 100644
--- a/src/openvpn/dco_freebsd.c
+++ b/src/openvpn/dco_freebsd.c
@@ -232,7 +232,6 @@  create_interface(struct tuntap *tt, const char *dev)
     snprintf(tt->dco.ifname, IFNAMSIZ, "%s", ifr.ifr_data);
-    tt->actual_name = string_alloc(tt->dco.ifname, NULL);
     /* see "Interface Flags" in ifnet(9) */
diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c
index b2fdbf53f..e5cea3c71 100644
--- a/src/openvpn/dco_linux.c
+++ b/src/openvpn/dco_linux.c
@@ -457,7 +457,6 @@  open_tun_dco(struct tuntap *tt, openvpn_net_ctx_t *ctx, const char *dev)
         msg(M_FATAL, "DCO: cannot retrieve ifindex for interface %s", dev);
-    tt->actual_name = string_alloc(dev, NULL);
     tt->dco.dco_message_peer_id = -1;