From: "flichtenheld (Code Review)" Date: Tue, 21 Oct 2025 16:17:49 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <3bf85336bb3e940b3580866d4acdc5aa66257a68-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/AJ/IelNSlE="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --/AJ/IelNSlE= 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/+/1292?usp=3Demail to review the following change. Change subject: multi: Fix wrong usage of mroute_extract_openvpn_sockaddr ...................................................................... multi: Fix wrong usage of mroute_extract_openvpn_sockaddr maddr.proto needs to be set before the call since that will change the behavior. Found by GCC "'maddr.proto' is used uninitialized" Change-Id: I76babf08b041162ddedf7a9b7c2799847f15cbdc Signed-off-by: Frank Lichtenheld --- M src/openvpn/multi.c M src/openvpn/push.c M src/openvpn/ssl_verify.c 3 files changed, 16 insertions(+), 20 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/92/1292/1 diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index e907524..fa9c654 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -3965,9 +3965,9 @@ saddr.addr.in4.sin_family =3D AF_INET; saddr.addr.in4.sin_addr.s_addr =3D htonl(addr); saddr.addr.in4.sin_port =3D htons(port); + maddr.proto =3D proto; if (mroute_extract_openvpn_sockaddr(&maddr, &saddr, true)) { - maddr.proto =3D proto; hash_iterator_init(m->iter, &hi); while ((he =3D hash_iterator_next(&hi))) { diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 2c717c7..1871816 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 --=20 To view, visit http://gerrit.openvpn.net/c/openvpn/+/1292?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: I76babf08b041162ddedf7a9b7c2799847f15cbdc Gerrit-Change-Number: 1292 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --/AJ/IelNSlE= 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

multi: Fix wrong usage of mroute_extract_op=
envpn_sockaddr

maddr.proto needs to be set before the call since tha= t
will change the behavior.

Found by GCC "'maddr.proto&#= 39; is used uninitialized"

Change-Id: I76babf08b041162ddedf7a9b= 7c2799847f15cbdc
Signed-off-by: Frank Lichtenheld <frank@...2641...&g= t;
---
M src/openvpn/multi.c
M src/openvpn/push.c
M src/openvpn= /ssl_verify.c
3 files changed, 16 insertions(+), 20 deletions(-)

=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/ch=
anges/92/1292/1
diff --git a/src/openvpn/multi.c b/src/openvpn/mult=
i.c
index e907524..fa9c654 100644
--- a/src= /openvpn/multi.c
+++ b/src/openvpn/multi.c
= @@ -3965,9 +3965,9 @@
saddr.addr.in4.sin_family =3D AF= _INET;
saddr.addr.in4.sin_addr.s_addr =3D htonl(addr);=
saddr.addr.in4.sin_port =3D htons(port);
+ maddr.proto =3D proto;
if (mroute_extract_openvpn_sockaddr(&maddr, &saddr,= true))
{
- maddr.proto =3D proto;
hash_itera= tor_init(m->iter, &hi);
while ((he =3D hash= _iterator_next(&hi)))
{
diff -= -git a/src/openvpn/push.c b/src/openvpn/push.c
index 2c717c= 7..1871816 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
-#pragm= a GCC diagnostic ignored "-Wconversion"
-#endif
-
bool
send_auth_pending_mess= ages(struct tls_multi *tls_multi, struct tls_session *session,
const char *extra, unsigned int timeout)
@@ -449,7 +444,12 @@
/* Calculate the ma= ximum 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_timeout =3D max_ti= meout - (now - ks->initial);
+ time_t time_elapsed =3D now - ks->initial;
+ if (time_elapsed < 0 || ti= me_elapsed >=3D (time_t)max_timeout)

+ {
+ return false;
+ }
+ ma= x_timeout -=3D (unsigned int)time_elapsed;
timeout =3D= min_uint(max_timeout, timeout);

str= uct 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, boo= l *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/ss= l_verify.c
@@ -874,11 +874,6 @@
return= supported;
}

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pus= h
-#pragma GCC diagnost= ic ignored "-Wconversion"
-#endif
-<= /span>
/**
* Checks if the deferred state shou= ld 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 pendin= g file timeout");
buffer_list_free(li= nes);
@@ -933,14 +929,13 @@
= pending_method);
auth_set_clien= t_reason(multi, buf);
msg(M_INFO,- "Clie= nt does not supported auth pending method "
- "'%s'",

+ &q= uot;Client does not supported auth pending method '%s'",
pending_method);
= ret =3D false;
}
= else
{
- send_auth_pending_messages(multi, sess= ion, BSTR(extra_buf), timeout);
+ send_auth_pending_messages(multi, session, BSTR= (extra_buf), (unsigned int)timeout);
}<= br> }

@@ -950,10 +945,6 @@<= /span>
return ret;
}

-#if defined(__GNUC__) || de= fined(__clang__)
-#prag= ma GCC diagnostic pop
-= #endif
-
/**

* Removes auth_pending and auth_control files fro= m file system
* and key_state structure
=

To view, visit change 1292. To unsubscribe, or for help wri= ting mail filters, visit settings.

=
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I76babf08b041162ddedf7a9b7c2= 799847f15cbdc
Gerrit-Change-Number: 1292
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...>
= --/AJ/IelNSlE=--