From: "flichtenheld (Code Review)" Date: Tue, 7 Oct 2025 11:15:05 +0000 In-Reply-To: References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, max@...2606..., gert@...1296... Message-ID: <0727375528d9e63fb8581afed52eab7489663909-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="K9R7pnmEZtk="; 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 , MaxF --K9R7pnmEZtk= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: MaxF, cron2, flichtenheld, plaisthos. Hello cron2, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1217?usp=3Demail to look at the new patch set (#4). The following approvals got outdated and were removed: Code-Review-1 by cron2, Code-Review-1 by flichtenheld 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, 7 insertions(+), 14 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1217/4 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: 4 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: MaxF Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld Gerrit-Attention: MaxF --K9R7pnmEZtk= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: MaxF, cron2, flichtenheld, plaisthos.

flichtenheld uploaded patch set #4 to this change.

<= p>View C= hange

The following approvals got outdated and were removed: Code-Review-1 by cron2, Code-Review-1 by flichtenheld

cryp=
to: Make some casts to int explicit

In all of these cases the cast i= s safe to do
since we have limits imposed in other ways.

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

Change-Id:= I3b8dd8d5671e31dba2a23a0a78f36d9dda034b88
Signed-off-by: Frank Lichtenh= eld <frank@...2641...>
---
M src/openvpn/crypto.c
1 file cha= nged, 7 insertions(+), 14 deletions(-)

git pull =
ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1217/4
diff =
--git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index 6= 376c11..307d1ee 100644
--- a/src/openvpn/crypto.c+++ b/src/openvpn/crypto.c
@@ -186,11 +186,6 @@
return;
}

-#if defined(__GNUC__) || defined(__= clang__)

-#pragma GCC d= iagnostic push
-#pragma= GCC diagnostic ignored "-Wconversion"
-#endif
-
static void
openvpn_encrypt_= 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(&wor= k) - hmac_start);
+ = hmac_ctx_update(ctx->hmac, hmac_start, (int)(BEND(&work) -= hmac_start));
hmac_ctx_final(ctx->hmac, ma= c_out);
dmsg(D_PACKET_CONTENT, "ENCRYPT H= MAC: %s",
format_hex(mac_out, hmac_c= tx_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_l= en =3D 0;
@@ -1366,8 +1361,8 @@
int st= ate =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(stati= c_key_head);
+ con= st int flen =3D (int)strlen(static_key_foot);
const in= t onekeylen =3D sizeof(key2->keys[0]);

CLEAR(*key2);

@@ -1378,7 +1373,9 @@
= */
if (flags & RKF_INLINE) /* 'file' = is a string containing ascii representation of key */
= {
- size =3D str= len(file) + 1;
+ = size_t buf_size =3D strlen(file) + 1;
+ ASSERT(buf_size <=3D INT_MAX);
+ size =3D (int)buf_size;<= /span>
buf_set_read(&in, (const uint8_t *)file, size)= ;
}
else /* 'file' is a f= ilename which refers to a file containing the ascii key */
= @@ -1537,10 +1534,6 @@
gc_free(&gc);
}


-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
int
write_key_file(const i= nt nkeys, const char *filename)
{
<= br>

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3b8dd8d5671e31dba2a23a0a78f= 36d9dda034b88
Gerrit-Change-Number: 1217
Gerrit-PatchSet: 4
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>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: MaxF <max@...2606...> =
= --K9R7pnmEZtk=--