From: "cron2 (Code Review)" Date: Mon, 17 Nov 2025 08:20:40 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <175dcdc1d609df3b6212ecd864559ede1ab48610-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="52+ec1SRJXw="; 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: flichtenheld Cc: plaisthos , openvpn-devel --52+ec1SRJXw= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/13= 60?usp=3Demail ) 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 Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1360 Message-Id: <20251117074921.26531-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 501.html Signed-off-by: Gert Doering --- M src/openvpn/ssl_pkt.c 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/openvpn/ssl_pkt.c b/src/openvpn/ssl_pkt.c index d7f7ac3..f216e88 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 P_KEY_ID_MASK); + 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: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I2a1786b2bf15852222c28e1b73ab7edbb5f19d7f Gerrit-Change-Number: 1360 Gerrit-PatchSet: 3 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --52+ec1SRJXw= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

ssl_pkt: Avoid conversion warnings

I cons= idered changing opcode to be uint8_t directly, but
most code treats it a= s int now, so that would be a much
bigger change. Similar for key_id.
Change-Id: I2a1786b2bf15852222c28e1b73ab7edbb5f19d7f
Signed-off-by:= Frank Lichtenheld <frank@...2641...>
Acked-by: Gert Doering <g= ert@...1296...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/13= 60
Message-Id: <20251117074921.26531-1-gert@...1296...>
URL: ht= tps://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34501.htm= l
Signed-off-by: Gert Doering <gert@...1296...>
---
M src/op= envpn/ssl_pkt.c
1 file changed, 4 insertions(+), 11 deletions(-)

=
diff --git a/src/openvpn/ssl_pkt.c b/src/openvpn/ssl_pkt.c
index d7f7ac3..f216e88 100644
--- a/src/openvpn/ssl_pkt.= c
+++ b/src/openvpn/ssl_pkt.c
@@ -160,17 +1= 60,14 @@
}
}
=
-#if defined(__GNUC__) || def= ined(__clang__)
-#pragm= a GCC diagnostic push
-= #pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
void
write_control_au= th(struct tls_session *session, struct key_state *ks, struct buffer *buf,
struct link_socket_actual **to_link_addr= , int opcode, int max_ack,
bool prepend= _ack)
{
+ ASSERT(ks->k= ey_id >=3D 0 && ks->key_id <=3D P_KEY_ID_MASK);
= + ASSERT(opcode >=3D 0 &a= mp;& opcode <=3D P_LAST_OPCODE);
+ uint8_t header =3D (uint8_t)(ks->key_id | (opcod= e << P_OPCODE_SHIFT));

/* Work= around for Softether servers. Softether has a bug that it only
* allows 4 ACks in packets and drops packets if more ACKs are con= tained

@@ -474,7 +471,7 @@
/* Get the = valid time quantisation for our hmac,
* we divide tim= e 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(hma= c);
/* We do not care about endian here since it does = not need to be
@@ -501,10 +498,6 @@
re= turn result.sid;
}

-#if defined(__GNUC__) || defined(__clang__)=
-#pragma GCC diagnosti= c pop
-#endif-
bool check_session_hmac_and_pkt_id(struct tls_pre_decrypt_state *state,=
const struct openvpn_sockad= dr *from,

To view, visit change 1360. To un= subscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2a1786b2bf15852222c28e1b73a= b7edbb5f19d7f
Gerrit-Change-Number: 1360
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --52+ec1SRJXw=--