From: "d12fk (Code Review)" Date: Thu, 12 Dec 2024 07:47:41 +0000 References: Reply-To: heiko@...515..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <3475f095bce1e8bb3549a7f35f6c4a45712b9ce6-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="e0rU5Vx9KVk="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dns: clone options via pointer instead of copy List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --e0rU5Vx9KVk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/835?usp=3Demail to review the following change. Change subject: dns: clone options via pointer instead of copy ...................................................................... dns: clone options via pointer instead of copy Change-Id: I12b8bb26c0cb70e50b2d42b1c69018894e9f080c Signed-off-by: Heiko Hund --- M src/openvpn/dns.c M src/openvpn/dns.h M src/openvpn/options.c 3 files changed, 10 insertions(+), 7 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/835/1 diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c index 15e7322..e22ea00 100644 --- a/src/openvpn/dns.c +++ b/src/openvpn/dns.c @@ -248,13 +248,15 @@ } 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 =3D clone_dns_domains(o.search_domains, gc); - clone.servers =3D clone_dns_servers(o.servers, gc); - clone.servers_prepull =3D clone_dns_servers(o.servers_prepull, gc); + clone.search_domains =3D clone_dns_domains(o->search_domains, gc); + clone.servers =3D clone_dns_servers(o->servers, gc); + clone.servers_prepull =3D clone_dns_servers(o->servers_prepull, gc); + return clone; } diff --git a/src/openvpn/dns.h b/src/openvpn/dns.h index a4ccb95..838ebe1 100644 --- a/src/openvpn/dns.h +++ b/src/openvpn/dns.h @@ -129,7 +129,8 @@ * @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. diff --git a/src/openvpn/options.c b/src/openvpn/options.c index fa22eca..cc723ca 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3311,7 +3311,7 @@ o->pre_connect->route_default_gateway =3D o->route_default_gateway; o->pre_connect->route_ipv6_default_gateway =3D o->route_ipv6_default_g= ateway; - o->pre_connect->dns_options =3D clone_dns_options(o->dns_options, &o->= gc); + o->pre_connect->dns_options =3D clone_dns_options(&o->dns_options, &o-= >gc); /* NCP related options that can be overwritten by a push */ o->pre_connect->ciphername =3D o->ciphername; @@ -3364,7 +3364,7 @@ /* Free DNS options and reset them to pre-pull state */ gc_free(&o->dns_options.gc); struct gc_arena dns_gc =3D gc_new(); - o->dns_options =3D clone_dns_options(pp->dns_options, &dns_gc); + o->dns_options =3D clone_dns_options(&pp->dns_options, &dns_gc); o->dns_options.gc =3D dns_gc; if (pp->client_nat_defined) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/835?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I12b8bb26c0cb70e50b2d42b1c69018894e9f080c Gerrit-Change-Number: 835 Gerrit-PatchSet: 1 Gerrit-Owner: d12fk Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --e0rU5Vx9KVk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

d12fk would like plaisthos and flichtenheld to review t= his change.

Vi= ew Change

dns: clone options via pointer instead of copy

Change-= Id: I12b8bb26c0cb70e50b2d42b1c69018894e9f080c
Signed-off-by: Heiko Hund = <heiko@...2662...>
---
M src/openvpn/dns.c
M src/openvpn/dns= .h
M src/openvpn/options.c
3 files changed, 10 insertions(+), 7 delet= ions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/chan=
ges/35/835/1
diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c
index 15e7322..e22ea00 100644
--- a/src/openvp= n/dns.c
+++ b/src/openvpn/dns.c
@@ -248,13 = +248,15 @@
}

struct dns= _options
-clone_dns_opt= ions(const struct dns_options o, struct gc_arena *gc)
+clone_dns_options(const struct dns_option= s *o, struct gc_arena *gc)
{
struct d= ns_options clone;
+
memset(&clone, 0, sizeof(clone));
- clone.search_domains =3D clone_dns_= domains(o.search_domains, gc);
- clone.servers =3D clone_dns_servers(o.servers, gc);
= - clone.servers_prepull =3D cl= one_dns_servers(o.servers_prepull, gc);
+ clone.search_domains =3D clone_dns_domains(o->se= arch_domains, gc);
+ = clone.servers =3D clone_dns_servers(o->servers, gc);
+ clone.servers_prepull =3D clone_= dns_servers(o->servers_prepull, gc);
+
return clone;
}<= /span>

diff --git a/src/openvpn/dns.h b/src/open= vpn/dns.h
index a4ccb95..838ebe1 100644
---= a/src/openvpn/dns.h
+++ b/src/openvpn/dns.h
@@ -129,7 +129,8 @@

* @param gc Pointer to t= he gc_arena to use for the clone
* @return T= he dns_options clone
*/
-struct dns_options clone_dns_options(const struct dns_o= ptions 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 pull= ed ones don't mix in.
diff --git a/src/openvpn/options.= c b/src/openvpn/options.c
index fa22eca..cc723ca 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/= options.c
@@ -3311,7 +3311,7 @@
o->= pre_connect->route_default_gateway =3D o->route_default_gateway;
o->pre_connect->route_ipv6_default_gateway =3D o->= ;route_ipv6_default_gateway;

- o->pre_connect->dns_options =3D clone_dn= s_options(o->dns_options, &o->gc);
+ o->pre_connect->dns_options =3D clone_dn= s_options(&o->dns_options, &o->gc);
<= br> /* NCP related options that can be overwritten by a push */
o->pre_connect->ciphername =3D o->ciphername;<= /span>
@@ -3364,7 +3364,7 @@
/* Free DNS = options and reset them to pre-pull state */
gc_fre= e(&o->dns_options.gc);
struct gc_arena dns_= gc =3D gc_new();
- = o->dns_options =3D clone_dns_options(pp->dns_options, &dns_gc)= ;
+ o->dns_= options =3D clone_dns_options(&pp->dns_options, &dns_gc);=
o->dns_options.gc =3D dns_gc;

if (pp->client_nat_defined)
<= br>

To view, visit change 835. To unsubscribe, or for help writing mail = filters, visit settings.=

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I12b8bb26c0cb70e50b2d42b1c69= 018894e9f080c
Gerrit-Change-Number: 835
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <heiko@...515...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--e0rU5Vx9KVk=--