From: "flichtenheld (Code Review)" Date: Wed, 24 Sep 2025 16:36:33 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="FYASo4lBK4I="; 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: plaisthos Cc: openvpn-devel --FYASo4lBK4I= 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/+/1217?usp=3Demail to review the following change. 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 --- M src/openvpn/crypto.c 1 file changed, 3 insertions(+), 12 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1217/1 diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 6376c11..13635fb 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; @@ -1378,7 +1373,7 @@ */ if (flags & RKF_INLINE) /* 'file' is a string containing ascii represe= ntation of key */ { - size =3D strlen(file) + 1; + size =3D (int)(strlen(file) + 1); 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 +1532,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 Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I3b8dd8d5671e31dba2a23a0a78f36d9dda034b88 Gerrit-Change-Number: 1217 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-MessageType: newchange --FYASo4lBK4I= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

crypto: Make some casts to int explicit

In all of the= se cases the cast is safe to do
since we have limits imposed in other wa= ys.

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

Change-Id: I3b8dd8d5671e31dba2a23a0a78f36d9dda034b88
Signed-off= -by: Frank Lichtenheld <frank@...2641...>
---
M src/openvpn/cry= pto.c
1 file changed, 3 insertions(+), 12 deletions(-)

git pul= l ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1217/1
dif=
f --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index= 6376c11..13635fb 100644
--- a/src/openvpn/crypto.c<= br>+++ b/src/openvpn/crypto.c
@@ -186,11 +186,6 @@
return;
}

<= span style=3D"color: hsl(0, 100%, 40%);">-#if defined(__GNUC__) || defined(= __clang__)

-#pragma GCC= diagnostic push
-#prag= ma GCC diagnostic ignored "-Wconversion"
-#endif
-
static void
openvpn_encryp= t_v1(struct buffer *buf, struct buffer work, struct crypto_options *opt)
{
@@ -302,7 +297,7 @@
= if (ctx->hmac)
{
= hmac_ctx_reset(ctx->hmac);
- hmac_ctx_update(ctx->hmac, hmac_start, BEND(&w= ork) - hmac_start);
+= hmac_ctx_update(ctx->hmac, hmac_start, (int)(BEND(&work)= - hmac_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 BP= TR(buf) - ad_start;
+= const int ad_size =3D (int)(BPTR(buf) - ad_start);

uint8_t *tag_ptr =3D NULL;
int data= _len =3D 0;
@@ -1378,7 +1373,7 @@
*/<= /span>
if (flags & RKF_INLINE) /* 'file' is a str= ing containing ascii representation of key */
{=
- size =3D strlen(file= ) + 1;
+ size = =3D (int)(strlen(file) + 1);
buf_set_read(&in,= (const uint8_t *)file, size);
}
= else /* 'file' is a filename which refers to a file containing the = ascii key */
@@ -1537,10 +1532,6 @@
gc= _free(&gc);
}

-#if defined(__GNUC__) || defined(__clang__)=
-#pragma GCC diagnosti= c pop
-#endif-
int write_key_file(const int nkeys, const char *filename)
{


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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3b8dd8d5671e31dba2a23a0a78f= 36d9dda034b88
Gerrit-Change-Number: 1217
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...>
Gerrit-MessageType: newchange
--FYASo4lBK4I=--