Skip to contentSkip to conversation

Change in openvpn[master]: Fix wrong byte order of --dns server

Openvpn-devel In review stipa (Code Review) 2 participants 6 messages Jul 31, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1753974592000.I37ca672f05e9d77ec586fa28dadc6dc752e574fb@...2715...

#1 lore raw

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/+/1125?usp=email

to review the following change.

Change subject: Fix wrong byte order of --dns server
......................................................................

Fix wrong byte order of --dns server

We already fixed it in commit 82fd89a04f, but
the fix got lost in 2dfc4f8.

tuntap_options require host byte order, and we store dns servers in struct dns_server in network byte order, what we got from getaddrinfo().

Fix (again) by converting to the host byte order.

Change-Id I37ca672f05e9d77ec586fa28dadc6dc752e574fb

---
M src/openvpn/options.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/25/1125/1

src/openvpn/options.c +1 -1
index 3ceada0..ff9addd 100644
@@ -3573,7 +3573,7 @@
             {
                 if (s->addr[i].family == AF_INET && tt->dns_len + 1 < N_DHCP_ADDR)
                 {
-                    tt->dns[tt->dns_len++] = s->addr[i].in.a4.s_addr;
+                    tt->dns[tt->dns_len++] = ntohl(s->addr[i].in.a4.s_addr);
                 }
                 else if (tt->dns6_len + 1 < N_DHCP_ADDR)
                 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1125?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I37ca672f05e9d77ec586fa28dadc6dc752e574fb
Gerrit-Change-Number: 1125
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1125?usp=email )

Change subject: Fix wrong byte order of --dns server
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1125?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I37ca672f05e9d77ec586fa28dadc6dc752e574fb
Gerrit-Change-Number: 1125
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Thu, 31 Jul 2025 15:28:42 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Fix wrong byte order of --dns server

In reply to a message not in the archive

From: Lev Stipakov <[email protected]...>

We already fixed it in commit 82fd89a04f, but
the fix got lost in 2dfc4f8.

tuntap_options require host byte order, and we store dns servers in struct dns_server in network byte order, what we got from getaddrinfo().

Fix (again) by converting to the host byte order.

Change-Id I37ca672f05e9d77ec586fa28dadc6dc752e574fb

---

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/+/1125
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/options.c +1 -1
index 3ceada0..ff9addd 100644
@@ -3573,7 +3573,7 @@
             {
                 if (s->addr[i].family == AF_INET && tt->dns_len + 1 < N_DHCP_ADDR)
                 {
-                    tt->dns[tt->dns_len++] = s->addr[i].in.a4.s_addr;
+                    tt->dns[tt->dns_len++] = ntohl(s->addr[i].in.a4.s_addr);
                 }
                 else if (tt->dns6_len + 1 < N_DHCP_ADDR)
                 {
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix wrong byte order of --dns server

Yeah, git rebase accident in the "offending" patch (patch was written, bug was fixed in the "to-be-moved" code, git rebase adjusted the "old" side, but had no way to fix this for the "new" side and nobody noticed).

Let's try to get better DNS coverage into the automated Windows test rig.

As for the test, just stared at the code and did a windows compile test - as Lev wrote, we have fixed this bug before (doubly annoying).

Your patch has been applied to the master branch.

commit 63fed92c96c23e061a64683cab431db1269e3f73

Author: Lev Stipakov
Date:   Thu Jul 31 17:29:06 2025 +0200
     Fix wrong byte order of --dns server

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg32460.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1125?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Fix wrong byte order of --dns server
......................................................................

Fix wrong byte order of --dns server

We already fixed it in commit 82fd89a04f, but
the fix got lost in 2dfc4f8.

tuntap_options require host byte order, and we store dns servers in struct dns_server in network byte order, what we got from getaddrinfo().

Fix (again) by converting to the host byte order.

Change-Id I37ca672f05e9d77ec586fa28dadc6dc752e574fb

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32460.html

---
M src/openvpn/options.c

1 file changed, 1 insertion(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/25/1125/2

src/openvpn/options.c +1 -1
index 3ceada0..ff9addd 100644
@@ -3573,7 +3573,7 @@
             {
                 if (s->addr[i].family == AF_INET && tt->dns_len + 1 < N_DHCP_ADDR)
                 {
-                    tt->dns[tt->dns_len++] = s->addr[i].in.a4.s_addr;
+                    tt->dns[tt->dns_len++] = ntohl(s->addr[i].in.a4.s_addr);
                 }
                 else if (tt->dns6_len + 1 < N_DHCP_ADDR)
                 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1125?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I37ca672f05e9d77ec586fa28dadc6dc752e574fb
Gerrit-Change-Number: 1125
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1125?usp=email )

Change subject: Fix wrong byte order of --dns server
......................................................................

Fix wrong byte order of --dns server

We already fixed it in commit 82fd89a04f, but
the fix got lost in 2dfc4f8.

tuntap_options require host byte order, and we store dns servers in struct dns_server in network byte order, what we got from getaddrinfo().

Fix (again) by converting to the host byte order.

Change-Id I37ca672f05e9d77ec586fa28dadc6dc752e574fb

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32460.html

---
M src/openvpn/options.c

1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/options.c +1 -1
index 3ceada0..ff9addd 100644
@@ -3573,7 +3573,7 @@
             {
                 if (s->addr[i].family == AF_INET && tt->dns_len + 1 < N_DHCP_ADDR)
                 {
-                    tt->dns[tt->dns_len++] = s->addr[i].in.a4.s_addr;
+                    tt->dns[tt->dns_len++] = ntohl(s->addr[i].in.a4.s_addr);
                 }
                 else if (tt->dns6_len + 1 < N_DHCP_ADDR)
                 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1125?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I37ca672f05e9d77ec586fa28dadc6dc752e574fb
Gerrit-Change-Number: 1125
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged