From: "d12fk (Code Review)" Date: Thu, 12 Dec 2024 07:47:42 +0000 References: Reply-To: heiko@...515..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <6389cf62a6846c2fbb37283949b0d6308d3510da-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="4IWAs9Oa2h0="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: dns: store IPv4 addresses in network byte order List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --4IWAs9Oa2h0= 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/+/834?usp=3Demail to review the following change. Change subject: dns: store IPv4 addresses in network byte order ...................................................................... dns: store IPv4 addresses in network byte order This is done so that inet_ntop(3) can be used with IPv4 name server addresses. It expects the binary address in network byte order. If they are not that way the address octets are reversed. Change-Id: I81d4bb0abdd421f5ba260c10c610918652334a4d Signed-off-by: Heiko Hund --- M src/openvpn/dns.c 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/34/834/1 diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c index 0539ca5..15e7322 100644 --- a/src/openvpn/dns.c +++ b/src/openvpn/dns.c @@ -121,7 +121,7 @@ if (ai->ai_family =3D=3D AF_INET) { struct sockaddr_in *sin =3D (struct sockaddr_in *)ai->ai_addr; - server->addr[server->addr_count].in.a4.s_addr =3D ntohl(sin->sin_a= ddr.s_addr); + server->addr[server->addr_count].in.a4.s_addr =3D sin->sin_addr.s_= addr; } else { @@ -384,7 +384,7 @@ if (s->addr[j].family =3D=3D AF_INET) { setenv_dns_option(es, "dns_server_%d_address_%d", i, j + 1, - print_in_addr_t(s->addr[j].in.a4.s_addr,= 0, &gc)); + print_in_addr_t(s->addr[j].in.a4.s_addr,= IA_NET_ORDER, &gc)); } else { @@ -443,7 +443,7 @@ const char *fmt_port; if (server->addr[j].family =3D=3D AF_INET) { - addr =3D print_in_addr_t(server->addr[j].in.a4.s_addr, 0, = &gc); + addr =3D print_in_addr_t(server->addr[j].in.a4.s_addr, IA_= NET_ORDER, &gc); fmt_port =3D " address =3D %s:%s"; } else -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/834?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: I81d4bb0abdd421f5ba260c10c610918652334a4d Gerrit-Change-Number: 834 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 --4IWAs9Oa2h0= 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: store IPv4 addresses in network byte order

This i= s done so that inet_ntop(3) can be used with IPv4 name server
addresses.= It expects the binary address in network byte order. If they
are not th= at way the address octets are reversed.

Change-Id: I81d4bb0abdd421f5= ba260c10c610918652334a4d
Signed-off-by: Heiko Hund <heiko@...2662...&= gt;
---
M src/openvpn/dns.c
1 file changed, 3 insertions(+), 3 del= etions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/ch=
anges/34/834/1
diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c
index 0539ca5..15e7322 100644
--- a/src/open= vpn/dns.c
+++ b/src/openvpn/dns.c
@@ -121,7= +121,7 @@
if (ai->ai_family =3D=3D AF_INET)=
{
struct sockaddr_in *sin =3D (stru= ct sockaddr_in *)ai->ai_addr;
- server->addr[server->addr_count].in.a4.s_addr =3D = ntohl(sin->sin_addr.s_addr);
+ server->addr[server->addr_count].in.a4.s_addr =3D= sin->sin_addr.s_addr;
}
else<= /span>
{
@@ -384,7 +384,7 @@
= if (s->addr[j].family =3D=3D AF_INET)
= {
setenv_dns_option(es, "dns_= server_%d_address_%d", i, j + 1,
- print_in_addr_t(s->add= r[j].in.a4.s_addr, 0, &gc));
+ print_in_addr_t(s->addr[j= ].in.a4.s_addr, IA_NET_ORDER, &gc));
}
else
{
@@ -443,7 +443,7 @@

const char *fmt_port;
if (server->addr[j].family =3D=3D AF_INET)
{
- addr =3D print_in_addr_t(server->addr[j].in.a4.s= _addr, 0, &gc);
+= addr =3D print_in_addr_t(server->addr[j].in.a4.s_addr, I= A_NET_ORDER, &gc);
fmt_port =3D "= address =3D %s:%s";
}
else


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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I81d4bb0abdd421f5ba260c10c61= 0918652334a4d
Gerrit-Change-Number: 834
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
--4IWAs9Oa2h0=--