From: "flichtenheld (Code Review)" Date: Tue, 21 Oct 2025 16:23:42 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <2c0d8ea3ee6fd5227be84e27121b09a236c3f06f-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="cYiqpyX0z7Q="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: push: Fix conversion issues related to timeout in send_auth_pending_m... List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --cYiqpyX0z7Q= 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/+/1293?usp=3Demail to review the following change. Change subject: push: Fix conversion issues related to timeout in send_auth= _pending_messages ...................................................................... push: Fix conversion issues related to timeout in send_auth_pending_messages Add additional checking to make sure that the required casts are safe. Change-Id: Icc31b7fa0da86220df45552aecc15dc6c769cd54 Signed-off-by: Frank Lichtenheld --- M src/openvpn/push.c M src/openvpn/ssl_verify.c 2 files changed, 15 insertions(+), 19 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1293/1 diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 6f146fc..a6f979d 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -429,11 +429,6 @@ gc_free(&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - bool send_auth_pending_messages(struct tls_multi *tls_multi, struct tls_session= *session, const char *extra, unsigned int timeout) @@ -449,7 +444,12 @@ /* Calculate the maximum timeout and subtract the time we already wait= ed */ unsigned int max_timeout =3D max_uint(tls_multi->opt.renegotiate_seconds / 2, tls_multi->opt.ha= ndshake_window); - max_timeout =3D max_timeout - (now - ks->initial); + time_t time_elapsed =3D now - ks->initial; + if (time_elapsed < 0 || time_elapsed >=3D (time_t)max_timeout) + { + return false; + } + max_timeout -=3D (unsigned int)time_elapsed; timeout =3D min_uint(max_timeout, timeout); struct gc_arena gc =3D gc_new(); @@ -734,6 +734,11 @@ return true; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + static bool send_push_options(struct context *c, struct buffer *buf, struct push_list = *push_list, int safe_cap, bool *push_sent, bool *multi_push) diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 04ef27e..fe95621 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -874,11 +874,6 @@ return supported; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /** * Checks if the deferred state should also send auth pending * request to the client. Also removes the auth_pending control file @@ -915,8 +910,9 @@ buf_chomp(iv_buf); buf_chomp(extra_buf); + errno =3D 0; long timeout =3D strtol(BSTR(timeout_buf), NULL, 10); - if (timeout =3D=3D 0) + if (timeout <=3D 0 || timeout > UINT_MAX || errno) { msg(M_WARN, "could not parse auth pending file timeout"); buffer_list_free(lines); @@ -933,14 +929,13 @@ pending_method); auth_set_client_reason(multi, buf); msg(M_INFO, - "Client does not supported auth pending method " - "'%s'", + "Client does not supported auth pending method '%s'", pending_method); ret =3D false; } else { - send_auth_pending_messages(multi, session, BSTR(extra_buf)= , timeout); + send_auth_pending_messages(multi, session, BSTR(extra_buf)= , (unsigned int)timeout); } } @@ -950,10 +945,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /** * Removes auth_pending and auth_control files from file system * and key_state structure -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1293?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Icc31b7fa0da86220df45552aecc15dc6c769cd54 Gerrit-Change-Number: 1293 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --cYiqpyX0z7Q= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

push: Fix conversion issues related to time=
out in send_auth_pending_messages

Add additional checking to make su= re that the required
casts are safe.

Change-Id: Icc31b7fa0da86220= df45552aecc15dc6c769cd54
Signed-off-by: Frank Lichtenheld <frank@...1665...= 641...>
---
M src/openvpn/push.c
M src/openvpn/ssl_verify.c
= 2 files changed, 15 insertions(+), 19 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/1293/1<=
/pre>
-#if defined(__GNUC__=
) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
<= span style=3D"color: hsl(0, 100%, 40%);">-#endif
-
bool
send_aut= h_pending_messages(struct tls_multi *tls_multi, struct tls_session *session= ,
const char *extra, unsigned i= nt timeout)
@@ -449,7 +444,12 @@
/* Ca= lculate the maximum timeout and subtract the time we already waited */
unsigned int max_timeout =3D
max_= uint(tls_multi->opt.renegotiate_seconds / 2, tls_multi->opt.handshake= _window);
- max_time= out =3D max_timeout - (now - ks->initial);
+ time_t time_elapsed =3D now - ks->initial;=
+ if (time_elapse= d < 0 || time_elapsed >=3D (time_t)max_timeout)
+ {
+ return false;
+ }
+ max_timeout -=3D (unsigned int)time_elapsed;
= timeout =3D min_uint(max_timeout, timeout);

= struct gc_arena gc =3D gc_new();
@@ -734,6 +734,= 11 @@
return true;
}
=
+#if defined(__GNUC= __) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#endif
+
static bool send_push_options(struct context *c, struct buffer *buf, struct pu= sh_list *push_list, int safe_cap,
bool *= push_sent, bool *multi_push)
diff --git a/src/openvpn/ssl_v= erify.c b/src/openvpn/ssl_verify.c
index 04ef27e..fe95621 1= 00644
--- a/src/openvpn/ssl_verify.c
+++ b/= src/openvpn/ssl_verify.c
@@ -874,11 +874,6 @@
return supported;

}

-#if defined(__GNUC__) || defined(_= _clang__)

-#pragma GCC = diagnostic push
-#pragm= a GCC diagnostic ignored "-Wconversion"
-#endif
-
/**
* Checks if the defer= red state should also send auth pending
* request to the= client. Also removes the auth_pending control file
@@ -915= ,8 +910,9 @@
buf_chomp(iv_buf);
buf_chomp(extra_buf);

+ errno =3D 0;
long timeout =3D strtol(BSTR(timeout_buf), NULL, 10);<= br>- if (timeout =3D= =3D 0)
+ i= f (timeout <=3D 0 || timeout > UINT_MAX || errno)
= {
msg(M_WARN, "could not pa= rse auth pending file timeout");
buff= er_list_free(lines);
@@ -933,14 +929,13 @@
= pending_method);
= auth_set_client_reason(multi, buf);
msg(M= _INFO,
- = "Client does not supported auth pending method "
<= span style=3D"color: hsl(0, 100%, 40%);">- "'%s= '",
+ = "Client does not supported auth pending method '%s= 9;",
pending_method);
<= span> ret =3D false;
}<= br> else
{
- send_auth_pending_messa= ges(multi, session, BSTR(extra_buf), timeout);
+ send_auth_pending_messages(multi= , session, BSTR(extra_buf), (unsigned int)timeout);
= }
}

@@ -95= 0,10 +945,6 @@
return ret;
}
-#if defined(= __GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-=
/**
* Removes auth_pending and auth_co= ntrol files from file system
* and key_state structure

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icc31b7fa0da86220df45552aecc= 15dc6c769cd54
Gerrit-Change-Number: 1293
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...>
= --cYiqpyX0z7Q=--