]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
dns: clone options via pointer instead of copy
authorHeiko Hund <heiko@ist.eigentlich.net>
Fri, 13 Dec 2024 16:46:30 +0000 (17:46 +0100)
committerGert Doering <gert@greenie.muc.de>
Sat, 21 Dec 2024 15:23:49 +0000 (16:23 +0100)
Change-Id: I12b8bb26c0cb70e50b2d42b1c69018894e9f080c
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20241213164630.266045-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30112.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/dns.c
src/openvpn/dns.h
src/openvpn/options.c

index 15e73223a0d1f7bf457376eefae977eda213a14d..e22ea0071ccae13e410345c59e3829d8e8230837 100644 (file)
@@ -248,13 +248,15 @@ clone_dns_servers(const struct dns_server *server, struct gc_arena *gc)
 }
 
 struct dns_options
-clone_dns_options(const struct dns_options o, struct gc_arena *gc)
+clone_dns_options(const struct dns_options *o, struct gc_arena *gc)
 {
     struct dns_options clone;
+
     memset(&clone, 0, sizeof(clone));
-    clone.search_domains = clone_dns_domains(o.search_domains, gc);
-    clone.servers = clone_dns_servers(o.servers, gc);
-    clone.servers_prepull = clone_dns_servers(o.servers_prepull, gc);
+    clone.search_domains = clone_dns_domains(o->search_domains, gc);
+    clone.servers = clone_dns_servers(o->servers, gc);
+    clone.servers_prepull = clone_dns_servers(o->servers_prepull, gc);
+
     return clone;
 }
 
index a4ccb9504b3f64ceb6d2514bdb38fd103e20805d..838ebe15cc743aa602cad843bcadb374cb75f12a 100644 (file)
@@ -129,7 +129,8 @@ bool dns_options_verify(int msglevel, const struct dns_options *o);
  * @param   gc          Pointer to the gc_arena to use for the clone
  * @return              The dns_options clone
  */
-struct dns_options clone_dns_options(const struct dns_options o, struct gc_arena *gc);
+struct dns_options clone_dns_options(const struct dns_options *o,
+                                     struct gc_arena *gc);
 
 /**
  * Saves and resets the server options, so that pulled ones don't mix in.
index d8dd51806a6b78df91f686c7c7ff32bcdf5dc56d..b2a3a8beebf67812bd909a4c0c00161c16c9b10a 100644 (file)
@@ -3311,7 +3311,7 @@ pre_connect_save(struct options *o)
     o->pre_connect->route_default_gateway = o->route_default_gateway;
     o->pre_connect->route_ipv6_default_gateway = o->route_ipv6_default_gateway;
 
-    o->pre_connect->dns_options = clone_dns_options(o->dns_options, &o->gc);
+    o->pre_connect->dns_options = clone_dns_options(&o->dns_options, &o->gc);
 
     /* NCP related options that can be overwritten by a push */
     o->pre_connect->ciphername = o->ciphername;
@@ -3364,7 +3364,7 @@ pre_connect_restore(struct options *o, struct gc_arena *gc)
         /* Free DNS options and reset them to pre-pull state */
         gc_free(&o->dns_options.gc);
         struct gc_arena dns_gc = gc_new();
-        o->dns_options = clone_dns_options(pp->dns_options, &dns_gc);
+        o->dns_options = clone_dns_options(&pp->dns_options, &dns_gc);
         o->dns_options.gc = dns_gc;
 
         if (pp->client_nat_defined)