[Openvpn-devel,v1] PUSH_UPDATE server: free temporary options after sending message

Message ID 20261013121338.27882-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] PUSH_UPDATE server: free temporary options after sending message |

Commit Message

Gert Doering Oct. 13, 2026, 12:13 p.m. UTC
  From: Marco Baffo <marco@mandelbit.com>

Clean up options on success and send failure to avoid leaking
memory allocated while parsing outgoing updates.

Change-Id: Ie4a7e0702a30d2a637c3dfe03f6c62d8a9901aae
Signed-off-by: Marco Baffo <marco@mandelbit.com>
Acked-by: Razvan Cojocaru <razvanc@mailbox.org>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1992
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1992
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Razvan Cojocaru <razvanc@mailbox.org>
  

Patch

diff --git a/src/openvpn/push_util.c b/src/openvpn/push_util.c
index 0213041..f867a8c 100644
--- a/src/openvpn/push_util.c
+++ b/src/openvpn/push_util.c
@@ -163,6 +163,7 @@ 
     {
         if (!send_control_channel_string(c, BSTR(&e->buf), D_PUSH))
         {
+            uninit_options(&o);
             return false;
         }
 
@@ -217,6 +218,7 @@ 
         update_vhash(m, mi, o.ifconfig_local, o.ifconfig_ipv6_local);
     }
 
+    uninit_options(&o);
     return true;
 }
 
diff --git a/tests/unit_tests/openvpn/mock_push_dependencies.c b/tests/unit_tests/openvpn/mock_push_dependencies.c
index 112bcfd..bf2ccf3 100644
--- a/tests/unit_tests/openvpn/mock_push_dependencies.c
+++ b/tests/unit_tests/openvpn/mock_push_dependencies.c
@@ -62,6 +62,13 @@ 
 {
 }
 
+void
+uninit_options(struct options *options)
+{
+    gc_free(&options->gc);
+    gc_free(&options->dns_options.gc);
+}
+
 bool
 options_postprocess_pull(struct options *options, struct env_set *es)
 {