[Openvpn-devel] Fix memory leak after sighup

Message ID 1535550583-21825-1-git-send-email-steffan.karger@fox-it.com
State Accepted
Headers show
Series
  • [Openvpn-devel] Fix memory leak after sighup
Related show

Commit Message

Steffan Karger Aug. 29, 2018, 1:49 p.m.
The c.es env_set is (re)allocated for each "sighup loop iteration", while
it was free'd only once at process shutdown.  Move the env_set_destroy()
call to match the same level as the env_set_create() call to fix that.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
---
 src/openvpn/openvpn.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Arne Schwabe Aug. 30, 2018, 10:56 a.m. | #1
Am 29.08.18 um 15:49 schrieb Steffan Karger:
> The c.es env_set is (re)allocated for each "sighup loop iteration", while
> it was free'd only once at process shutdown.  Move the env_set_destroy()
> call to match the same level as the env_set_create() call to fix that.
> 

Acked-by: Arne Schwabe <arne@rfc2549.org>

This like the right fix and even though the leak is small we should fix
it nevertheless.

Arne

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Gert Doering Sept. 3, 2018, 8:39 a.m. | #2
Your patch has been applied to the master and release/2.4 branch (bugfix).

commit 7170bef507bfe74ceb4a12f8f10df4d2d6ad39c9 (master)
commit 8fcfe1d449a64e1ce61e361dc593ff52293b41f2 (release/2.4)
Author: Steffan Karger
Date:   Wed Aug 29 15:49:43 2018 +0200

     Fix memory leak after sighup

     Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <1535550583-21825-1-git-send-email-steffan.karger@fox-it.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17429.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Patch

diff --git a/src/openvpn/openvpn.c b/src/openvpn/openvpn.c
index b9e914a..3819889 100644
--- a/src/openvpn/openvpn.c
+++ b/src/openvpn/openvpn.c
@@ -329,6 +329,7 @@  openvpn_main(int argc, char *argv[])
             }
             while (c.sig->signal_received == SIGUSR1);
 
+            env_set_destroy(c.es);
             uninit_options(&c.options);
             gc_reset(&c.gc);
         }
@@ -337,8 +338,6 @@  openvpn_main(int argc, char *argv[])
 
     context_gc_free(&c);
 
-    env_set_destroy(c.es);
-
 #ifdef ENABLE_MANAGEMENT
     /* close management interface */
     close_management();