From: "cron2 (Code Review)" Date: Wed, 8 Oct 2025 09:44:30 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., max@...2606... Message-ID: <674dffec64147fee1a66500788d79a830b240591-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="TxEc0GLAiWE="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: crypto: Make some casts to int explicit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel , MaxF --TxEc0GLAiWE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#5) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1217?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: crypto: Make some casts to int explicit ...................................................................... crypto: Make some casts to int explicit In all of these cases the cast is safe to do since we have limits imposed in other ways. And we want those values as int, so no alternative to casting. Change-Id: I3b8dd8d5671e31dba2a23a0a78f36d9dda034b88 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1217 Message-Id: <20251008092859.875-1-gert@...1296...> URL: https://sourceforge.net/p/openvpn/mailman/message/59243794/ Signed-off-by: Gert Doering --- M src/openvpn/crypto.c 1 file changed, 7 insertions(+), 14 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1217/5 diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 6376c11..307d1ee 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -186,11 +186,6 @@ return; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static void openvpn_encrypt_v1(struct buffer *buf, struct buffer work, struct crypto_o= ptions *opt) { @@ -302,7 +297,7 @@ if (ctx->hmac) { hmac_ctx_reset(ctx->hmac); - hmac_ctx_update(ctx->hmac, hmac_start, BEND(&work) - hmac_star= t); + hmac_ctx_update(ctx->hmac, hmac_start, (int)(BEND(&work) - hma= c_start)); hmac_ctx_final(ctx->hmac, mac_out); dmsg(D_PACKET_CONTENT, "ENCRYPT HMAC: %s", format_hex(mac_out, hmac_ctx_size(ctx->hmac), 80, &gc)); @@ -533,7 +528,7 @@ } } - const int ad_size =3D BPTR(buf) - ad_start; + const int ad_size =3D (int)(BPTR(buf) - ad_start); uint8_t *tag_ptr =3D NULL; int data_len =3D 0; @@ -1366,8 +1361,8 @@ int state =3D PARSE_INITIAL; /* constants */ - const int hlen =3D strlen(static_key_head); - const int flen =3D strlen(static_key_foot); + const int hlen =3D (int)strlen(static_key_head); + const int flen =3D (int)strlen(static_key_foot); const int onekeylen =3D sizeof(key2->keys[0]); CLEAR(*key2); @@ -1378,7 +1373,9 @@ */ if (flags & RKF_INLINE) /* 'file' is a string containing ascii represe= ntation of key */ { - size =3D strlen(file) + 1; + size_t buf_size =3D strlen(file) + 1; + ASSERT(buf_size <=3D INT_MAX); + size =3D (int)buf_size; buf_set_read(&in, (const uint8_t *)file, size); } else /* 'file' is a filename which refers to a file containing the asc= ii key */ @@ -1537,10 +1534,6 @@ gc_free(&gc); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int write_key_file(const int nkeys, const char *filename) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1217?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I3b8dd8d5671e31dba2a23a0a78f36d9dda034b88 Gerrit-Change-Number: 1217 Gerrit-PatchSet: 5 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: MaxF Gerrit-CC: openvpn-devel --TxEc0GLAiWE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #5 to the change originally created by flichtenhel= d.

View Change

The following approvals got outdated and were remove= d: Code-Review+2 by cron2

crypto: Make some casts to int expl=
icit

In all of these cases the cast is safe to do
since we have l= imits imposed in other ways.

And we want those values as int, so no<= br>alternative to casting.

Change-Id: I3b8dd8d5671e31dba2a23a0a78f36= d9dda034b88
Signed-off-by: Frank Lichtenheld <frank@...2641...>Acked-by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerr= it.openvpn.net/c/openvpn/+/1217
Message-Id: <20251008092859.875-1-ger= t@...1296...>
URL: https://sourceforge.net/p/openvpn/mailman/message/= 59243794/
Signed-off-by: Gert Doering <gert@...1296...>
---
= M src/openvpn/crypto.c
1 file changed, 7 insertions(+), 14 deletions(-)<= br>
git pull ssh://gerrit.openvpn.net:29418/openvpn =
refs/changes/17/1217/5
diff --git a/src/openvpn/crypto.c b/src/open=
vpn/crypto.c
index 6376c11..307d1ee 100644
= --- a/src/openvpn/crypto.c
+++ b/src/openvpn/crypto.c
@@ -186,11 +186,6 @@
return;
}


= -#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconvers= ion"
-#endif
-
static vo= id
openvpn_encrypt_v1(struct buffer *buf, struct buffer wo= rk, struct crypto_options *opt)
{
@@ -302,= 7 +297,7 @@
if (ctx->hmac)
= {
hmac_ctx_reset(ctx->hmac);- hmac_ctx_update(ctx= ->hmac, hmac_start, BEND(&work) - hmac_start);
+ hmac_ctx_update(ctx->hmac,= hmac_start, (int)(BEND(&work) - hmac_start));
= hmac_ctx_final(ctx->hmac, mac_out);
dm= sg(D_PACKET_CONTENT, "ENCRYPT HMAC: %s",
= format_hex(mac_out, hmac_ctx_size(ctx->hmac), 80, &gc));
@@ -533,7 +528,7 @@
}
}


- const int ad_size =3D BPTR(buf) - ad_start;
+ const int ad_size =3D (int)(BPTR(buf)= - ad_start);

uint8_t *tag_ptr =3D N= ULL;
int data_len =3D 0;
@@ -1366,8 +1= 361,8 @@
int state =3D PARSE_INITIAL;
=
/* constants */
- const int hlen =3D strlen(static_key_head);
= - const int flen =3D strlen(st= atic_key_foot);
+ = const int hlen =3D (int)strlen(static_key_head);
+ const int flen =3D (int)strlen(static_key_= foot);
const int onekeylen =3D sizeof(key2->keys[0]= );

CLEAR(*key2);
@@ = -1378,7 +1373,9 @@
*/
if (flags = & RKF_INLINE) /* 'file' is a string containing ascii representa= tion of key */
{
- size =3D strlen(file) + 1;
+ size_t buf_size =3D strlen(file) + 1= ;
+ ASSERT(buf= _size <=3D INT_MAX);
+ size =3D (int)buf_size;
buf_set_read(&= amp;in, (const uint8_t *)file, size);
}
else /* 'file' is a filename which refers to a file containi= ng the ascii key */

@@ -1537,10 +1534,6 @@
= gc_free(&gc);
}

-#if defined(__GNUC__) || defined(__cl= ang__)
-#pragma GCC dia= gnostic pop
-#endif
-
int
write_key_file(const int nkeys, const char *filename)<= br> {

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3b8dd8d5671e31dba2a23a0a78f= 36d9dda034b88
Gerrit-Change-Number: 1217
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: MaxF <max@...2606...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --TxEc0GLAiWE=--