From: "flichtenheld (Code Review)" Date: Fri, 22 Aug 2025 16:25:18 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <3496710a52e7f8d913ff7dcd1b82a1cc2f8f9a79-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="RAmZZTaxNIE="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: options: Move < 0 check for keepalive settings earlier List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --RAmZZTaxNIE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1155?usp=3Demail to review the following change. Change subject: options: Move < 0 check for keepalive settings earlier ...................................................................... options: Move < 0 check for keepalive settings earlier Use the atoi_constrained function. Change-Id: Ic9ac18f730e6035126ccf1cf19799548e5fd9316 Signed-off-by: Frank Lichtenheld --- M src/openvpn/helper.c M src/openvpn/options.c 2 files changed, 3 insertions(+), 7 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1155/1 diff --git a/src/openvpn/helper.c b/src/openvpn/helper.c index b2ecb1e..b262e8d 100644 --- a/src/openvpn/helper.c +++ b/src/openvpn/helper.c @@ -552,14 +552,10 @@ /* * Sanity checks. */ - if (o->keepalive_ping <=3D 0 || o->keepalive_timeout <=3D 0) - { - msg(M_USAGE, "--keepalive parameters must be > 0"); - } if (o->keepalive_ping * 2 > o->keepalive_timeout) { msg(M_USAGE, - "the second parameter to --keepalive (restart timeout=3D%d= ) must be at least twice the value of the first parameter (ping interval=3D= %d). A ratio of 1:5 or 1:6 would be even better. Recommended setting is -= -keepalive 10 60.", + "The second parameter to --keepalive (restart timeout=3D%d= ) must be at least twice the value of the first parameter (ping interval=3D= %d). A ratio of 1:5 or 1:6 would be even better. Recommended setting is -= -keepalive 10 60.", o->keepalive_timeout, o->keepalive_ping); } if (o->ping_send_timeout || o->ping_rec_timeout) diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 87c0895..97bf957 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -7362,8 +7362,8 @@ else if (streq(p[0], "keepalive") && p[1] && p[2] && !p[3]) { VERIFY_PERMISSION(OPT_P_GENERAL); - options->keepalive_ping =3D atoi_warn(p[1], msglevel); - options->keepalive_timeout =3D atoi_warn(p[2], msglevel); + atoi_constrained(p[1], &options->keepalive_ping, "keepalive ping",= 0, 0, msglevel); + atoi_constrained(p[2], &options->keepalive_timeout, "keepalive tim= eout", 0, 0, msglevel); } else if (streq(p[0], "ping") && p[1] && !p[2]) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1155?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: Ic9ac18f730e6035126ccf1cf19799548e5fd9316 Gerrit-Change-Number: 1155 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --RAmZZTaxNIE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

options: Move < 0 check for keepalive settings earlier
Use the atoi_constrained function.

Change-Id: Ic9ac18f730e60351= 26ccf1cf19799548e5fd9316
Signed-off-by: Frank Lichtenheld <frank@...1665...= 641...>
---
M src/openvpn/helper.c
M src/openvpn/options.c
2= files changed, 3 insertions(+), 7 deletions(-)

git pull ssh://ge=
rrit.openvpn.net:29418/openvpn refs/changes/55/1155/1
diff --git a/=
src/openvpn/helper.c b/src/openvpn/helper.c
index b2ecb1e..= b262e8d 100644
--- a/src/openvpn/helper.c
+= ++ b/src/openvpn/helper.c
@@ -552,14 +552,10 @@
<= span> /*
* Sanity checks.
*/
- = if (o->keepalive_ping <=3D 0 || o->keepalive_timeout <=3D 0)
- {
- msg(M_USAGE, "--kee= palive parameters must be > 0");

- }
if (o->keepalive_p= ing * 2 > o->keepalive_timeout)
{
= msg(M_USAGE,
- "the second parameter to --keepalive (restar= t timeout=3D%d) must be at least twice the value of the first parameter (pi= ng interval=3D%d). A ratio of 1:5 or 1:6 would be even better. Recommende= d setting is --keepalive 10 60.",
+ "The second parameter to --keepaliv= e (restart timeout=3D%d) must be at least twice the value of the first para= meter (ping interval=3D%d). A ratio of 1:5 or 1:6 would be even better. R= ecommended setting is --keepalive 10 60.",
= o->keepalive_timeout, o->keepalive_ping);
= }
if (o->ping_send_timeout || o->ping_re= c_timeout)
diff --git a/src/openvpn/options.c b/src/openvpn= /options.c
index 87c0895..97bf957 100644
--= - a/src/openvpn/options.c
+++ b/src/openvpn/options.c

@@ -7362,8 +7362,8 @@
else if (streq(p[0], = "keepalive") && p[1] && p[2] && !p[3])
{
VERIFY_PERMISSION(OPT_P_GENER= AL);
- options-&= gt;keepalive_ping =3D atoi_warn(p[1], msglevel);
- options->keepalive_timeout =3D atoi_w= arn(p[2], msglevel);
= + atoi_constrained(p[1], &options->keepalive_ping, "keep= alive ping", 0, 0, msglevel);
+ atoi_constrained(p[2], &options->keepalive_ti= meout, "keepalive timeout", 0, 0, msglevel);
= }
else if (streq(p[0], "ping") && p= [1] && !p[2])
{

To view, visit change 1155. To unsubscribe, or for help writing mail filt= ers, visit settings.

=
<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9ac18f730e6035126ccf1cf197= 99548e5fd9316
Gerrit-Change-Number: 1155
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
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-MessageType: newchange
--RAmZZTaxNIE=--