Change in openvpn[master]: win: calculate address string buffer size
A message that is not in the archive (sent off-list or not yet received): gerrit.1741926089000.I23710b1f5b2122ec1f14465911836c0f0afa9c64@...2715...
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/+/908?usp=email
to review the following change.
Change subject: win: calculate address string buffer size
......................................................................
win: calculate address string buffer size
Instead of making the string buffer statically sized for a max. of four addresses, calculate it to hold up to the max number of addresses a dns_cfg_message_t can hold (currently four as well). Improves the code so that it doesn't rely on the addresses never being more than four in the future.
---
M src/openvpnserv/interactive.c
1 file changed, 4 insertions(+), 3 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/08/908/1
src/openvpnserv/interactive.c +4 -3
@@ -1866,9 +1866,10 @@int addr_len = msg->addr_len;/* sanity check */ -if (addr_len >_countof (msg->addr)) +const size_t max_addrs =_countof (msg->addr); +if (addr_len > max_addrs) { - addr_len =_countof (msg->addr); + addr_len = max_addrs; }if (!msg->iface.name[0 ])/* interface name is required */
@@ -1918,7 +1919,7 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[256 ];/* large enough to hold four IPv4 / IPv6 address strings */ +CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/908?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: I23710b1f5b2122ec1f14465911836c0f0afa9c64
Gerrit-Change-Number: 908
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[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
Attention is currently required from: d12fk, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/908?usp=email )
Change subject: win: calculate address string buffer size
......................................................................
Patch Set 6: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/908?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: I23710b1f5b2122ec1f14465911836c0f0afa9c64
Gerrit-Change-Number: 908
Gerrit-PatchSet: 6
Gerrit-Owner: d12fk <[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: d12fk <[email protected]...>
Gerrit-Comment-Date: Thu, 20 Mar 2025 17:13:57 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v6 1/1 win: calculate address string buffer size
In reply to a message not in the archiveFrom: Heiko Hund <[email protected]...>
Instead of making the string buffer statically sized for a max. of four addresses, calculate it to hold up to the max number of addresses a dns_cfg_message_t can hold (currently four as well). Improves the code so that it doesn't rely on the addresses never being more than four in the future.
---
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/+/908
This mail reflects revision 6 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>
src/openvpnserv/interactive.c +4 -3
@@ -1857,9 +1857,10 @@int addr_len = msg->addr_len;/* sanity check */ -if (addr_len >_countof (msg->addr)) +const size_t max_addrs =_countof (msg->addr); +if (addr_len > max_addrs) { - addr_len =_countof (msg->addr); + addr_len = max_addrs; }if (!msg->iface.name[0 ])/* interface name is required */
@@ -1909,7 +1910,7 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[256 ];/* large enough to hold four IPv4 / IPv6 address strings */ +CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
[Openvpn-devel] [PATCH applied] Re: win: calculate address string buffer size
Thanks for future-proofing this part of the code - it's fine today, but we might bump the number of allowed DNS addresses to "8" one day, and then the old code was at-risk for overflows...
I haven't actually tested it, just stared at it for a bit, asked mingw ("no warnings") and we have Frank's +2 in gerrit.
Your patch has been applied to the master branch.
commit 8ea5debaea01da5fee56fbad56b50820c1beee92
Author: Heiko Hund Date: Mon Mar 24 09:33:44 2025 +0100
win: calculate address string buffer size
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: Frank Lichtenheld <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31196.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#7) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/908?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: win: calculate address string buffer size
......................................................................
win: calculate address string buffer size
Instead of making the string buffer statically sized for a max. of four addresses, calculate it to hold up to the max number of addresses a dns_cfg_message_t can hold (currently four as well). Improves the code so that it doesn't rely on the addresses never being more than four in the future.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31196.html
---
M src/openvpnserv/interactive.c
1 file changed, 4 insertions(+), 3 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/08/908/7
src/openvpnserv/interactive.c +4 -3
@@ -1848,9 +1848,10 @@int addr_len = msg->addr_len;/* sanity check */ -if (addr_len >_countof (msg->addr)) +const size_t max_addrs =_countof (msg->addr); +if (addr_len > max_addrs) { - addr_len =_countof (msg->addr); + addr_len = max_addrs; }if (!msg->iface.name[0 ])/* interface name is required */
@@ -1900,7 +1901,7 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[256 ];/* large enough to hold four IPv4 / IPv6 address strings */ +CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/908?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: I23710b1f5b2122ec1f14465911836c0f0afa9c64
Gerrit-Change-Number: 908
Gerrit-PatchSet: 7
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/908?usp=email )
Change subject: win: calculate address string buffer size
......................................................................
win: calculate address string buffer size
Instead of making the string buffer statically sized for a max. of four addresses, calculate it to hold up to the max number of addresses a dns_cfg_message_t can hold (currently four as well). Improves the code so that it doesn't rely on the addresses never being more than four in the future.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31196.html
---
M src/openvpnserv/interactive.c
1 file changed, 4 insertions(+), 3 deletions(-)
src/openvpnserv/interactive.c +4 -3
@@ -1848,9 +1848,10 @@int addr_len = msg->addr_len;/* sanity check */ -if (addr_len >_countof (msg->addr)) +const size_t max_addrs =_countof (msg->addr); +if (addr_len > max_addrs) { - addr_len =_countof (msg->addr); + addr_len = max_addrs; }if (!msg->iface.name[0 ])/* interface name is required */
@@ -1900,7 +1901,7 @@if (msg->addr_len >0 ) {/* prepare the comma separated address list */ -CHAR addrs[256 ];/* large enough to hold four IPv4 / IPv6 address strings */ +CHAR addrs[max_addrs *64 ];/* 64 is enough for one IPv4/6 address */ size_t offset =0 ;for (int i =0 ; i < addr_len; ++i) {
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/908?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: I23710b1f5b2122ec1f14465911836c0f0afa9c64
Gerrit-Change-Number: 908
Gerrit-PatchSet: 7
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged