[Openvpn-devel] Properly free tuntap struct on android when emulating persist-tun

Message ID 20180912110701.31609-1-arne@rfc2549.org
State Accepted
Headers show
Series [Openvpn-devel] Properly free tuntap struct on android when emulating persist-tun | expand

Commit Message

Arne Schwabe Sept. 12, 2018, 1:07 a.m. UTC
Trac-Ticket: #851
---
 src/openvpn/init.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Gert Doering Sept. 25, 2018, 4:28 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

"It does what it says on the lid" - do_init_tun() will allocate a new
struct tuntap, so if we have one beforehand, it needs free()ing.  

I have not actively *tested* it, as I have no test rig for building 
Android binaries - OTOH, if the one who gets all the blame for Android 
says it's ok, I'm going to believe it (no other platform affected).

Your patch has been applied to the master and release/2.4 branch
(2.4 mostly due to "it's a bugfix, it's a single platform, and 
to keep the code similar for future changes").

commit da3f583f30a4b2be9cc5501874373fc4f627158d (master)
commit 21a307dd7252a066f204dee52a4cf569a4a48a1d (release/2.4)
Author: Arne Schwabe
Date:   Wed Sep 12 13:07:01 2018 +0200

     Properly free tuntap struct on android when emulating persist-tun

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


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 2933d555..b1f4320a 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -1680,6 +1680,9 @@  do_open_tun(struct context *c)
     if (c->c1.tuntap)
     {
         oldtunfd = c->c1.tuntap->fd;
+        free(c->c1.tuntap);
+        c->c1.tuntap = NULL;
+        c->c1.tuntap_owned = false;
     }
 #endif