]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix memory leak in add_option() for option 'connection'
authorGuido Vranken <guidovranken@gmail.com>
Thu, 8 Jun 2017 22:04:36 +0000 (00:04 +0200)
committerGert Doering <gert@greenie.muc.de>
Sat, 10 Jun 2017 07:19:04 +0000 (09:19 +0200)
This patch ensures that if an error occurs while processing
the 'connection' directive of an options specification,
the variable 'struct options sub', which is initialized
with init_options(), is properly freed with uninit_options().

Signed-off-by: Guido Vranken <guidovranken@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <CAO5O-E+HdfHNAK=--55054AB374U-Ky4q_-3M114makfPdSnBw@mail.gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14764.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/options.c

index 452087adeedd20479828ff5872cfa610fbfb9eb2..f66bd2fdab101743d366c96b683549b9718848e5 100644 (file)
@@ -5302,12 +5302,14 @@ add_option(struct options *options,
             if (!sub.ce.remote)
             {
                 msg(msglevel, "Each 'connection' block must contain exactly one 'remote' directive");
+                uninit_options(&sub);
                 goto err;
             }
 
             e = alloc_connection_entry(options, msglevel);
             if (!e)
             {
+                uninit_options(&sub);
                 goto err;
             }
             *e = sub.ce;