From: "flichtenheld (Code Review)" Date: Fri, 7 Nov 2025 16:18:51 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <28fd5ef796cb80de230827e6ba41da6e2ffe374f-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="T74QLebAgzM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: ssl_pkt: Avoid conversion warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --T74QLebAgzM= 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/+/1360?usp=3Demail to review the following change. Change subject: ssl_pkt: Avoid conversion warnings ...................................................................... ssl_pkt: Avoid conversion warnings I considered changing opcode to be uint8_t directly, but most code treats it as int now, so that would be a much bigger change. Similar for key_id. Change-Id: I2a1786b2bf15852222c28e1b73ab7edbb5f19d7f Signed-off-by: Frank Lichtenheld --- M src/openvpn/ssl_pkt.c 1 file changed, 4 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60/1360/1 diff --git a/src/openvpn/ssl_pkt.c b/src/openvpn/ssl_pkt.c index d7f7ac3..77803ec 100644 --- a/src/openvpn/ssl_pkt.c +++ b/src/openvpn/ssl_pkt.c @@ -160,17 +160,14 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - void write_control_auth(struct tls_session *session, struct key_state *ks, stru= ct buffer *buf, struct link_socket_actual **to_link_addr, int opcode, i= nt max_ack, bool prepend_ack) { - uint8_t header =3D ks->key_id | (opcode << P_OPCODE_SHIFT); + ASSERT(ks->key_id >=3D 0 && ks->key_id <=3D 1 << P_OPCODE_SHIFT); + ASSERT(opcode >=3D 0 && opcode <=3D P_LAST_OPCODE); + uint8_t header =3D (uint8_t)(ks->key_id | (opcode << P_OPCODE_SHIFT)); /* Workaround for Softether servers. Softether has a bug that it only * allows 4 ACks in packets and drops packets if more ACKs are contain= ed @@ -474,7 +471,7 @@ /* Get the valid time quantisation for our hmac, * we divide time by handwindow/2 and allow the previous * and future session time if specified by offset */ - uint32_t session_id_time =3D ntohl(now / ((handwindow + 1) / 2) + offs= et); + uint32_t session_id_time =3D ntohl((uint32_t)(now / ((handwindow + 1) = / 2) + offset)); hmac_ctx_reset(hmac); /* We do not care about endian here since it does not need to be @@ -501,10 +498,6 @@ return result.sid; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - bool check_session_hmac_and_pkt_id(struct tls_pre_decrypt_state *state, const struct openvpn_sockaddr *from, -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1360?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: I2a1786b2bf15852222c28e1b73ab7edbb5f19d7f Gerrit-Change-Number: 1360 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --T74QLebAgzM= 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

ssl_pkt: Avoid conversion warnings

I= considered changing opcode to be uint8_t directly, but
most code treats= it as int now, so that would be a much
bigger change. Similar for key_i= d.

Change-Id: I2a1786b2bf15852222c28e1b73ab7edbb5f19d7f
Signed-of= f-by: Frank Lichtenheld <frank@...2641...>
---
M src/openvpn/ss= l_pkt.c
1 file changed, 4 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/60= /1360/1
diff --git a/src/openvpn/ssl_pkt.c b/src/openvpn/ssl_pkt.c<=
/span>
index d7f7ac3..77803ec 100644
--- a/src/ope= nvpn/ssl_pkt.c
+++ b/src/openvpn/ssl_pkt.c
= @@ -160,17 +160,14 @@
}
}
<= span>

-#if defined(__G= NUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"=
-#endif
-
void
wri= te_control_auth(struct tls_session *session, struct key_state *ks, struct b= uffer *buf,
struct link_socket_actual *= *to_link_addr, int opcode, int max_ack,
= bool prepend_ack)
{
- uint8_t header =3D ks->key_id | (opcode << P_O= PCODE_SHIFT);
+ AS= SERT(ks->key_id >=3D 0 && ks->key_id <=3D 1 << P_= OPCODE_SHIFT);
+ A= SSERT(opcode >=3D 0 && opcode <=3D P_LAST_OPCODE);
= + uint8_t header =3D (uint8_= t)(ks->key_id | (opcode << P_OPCODE_SHIFT));

/* Workaround for Softether servers. Softether has a bug = that it only
* allows 4 ACks in packets and drops pac= kets if more ACKs are contained
@@ -474,7 +471,7 @@<= br> /* Get the valid time quantisation for our hmac,
* we divide time by handwindow/2 and allow the previous
* and future session time if specified by offset */
= - uint32_t session_id_time =3D= ntohl(now / ((handwindow + 1) / 2) + offset);
+ uint32_t session_id_time =3D ntohl((uint32_t= )(now / ((handwindow + 1) / 2) + offset));

hmac_ctx_reset(hmac);
/* We do not care about e= ndian here since it does not need to be
@@ -501,10 +498,6 @= @
return result.sid;
}

-#if defined(__GNUC= __) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
bool
check_session_hmac_and_pkt_id(struct tls_= pre_decrypt_state *state,
co= nst struct openvpn_sockaddr *from,

To v= iew, visit change 1360. To unsubscribe, or for help writing mail filters, visit= settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2a1786b2bf15852222c28e1b73a= b7edbb5f19d7f
Gerrit-Change-Number: 1360
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...>
= --T74QLebAgzM=--