From: "cron2 (Code Review)" Date: Tue, 28 Oct 2025 19:22:24 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <43b15b447e09710b99f214cb44a2266ce5d200e2-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="WKTVayXhPIM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: crypto_backend: Change len argument of md_ctx_update to size_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: plaisthos , openvpn-devel --WKTVayXhPIM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/12= 87?usp=3Demail ) Change subject: crypto_backend: Change len argument of md_ctx_update to siz= e_t ...................................................................... crypto_backend: Change len argument of md_ctx_update to size_t The underlying APIs already use size_t and all the users (only httpdigest and push) already put size_t into it. So avoid conversion warnings. Also fix one trivial conversion warning in push.c to able to easily remove the -Wconversion override from the affected code paths. Change-Id: I27f2fcd903d26ccbfbd0cdc45f99cc3cd8b0e49a Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1287 Message-Id: <20251028185706.1247-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33= 973.html Signed-off-by: Gert Doering --- M src/openvpn/crypto_backend.h M src/openvpn/crypto_mbedtls.c M src/openvpn/crypto_openssl.c M src/openvpn/httpdigest.c M src/openvpn/push.c 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h index 4d6a96c..e95752a 100644 --- a/src/openvpn/crypto_backend.h +++ b/src/openvpn/crypto_backend.h @@ -599,7 +599,7 @@ * @param src Buffer to digest. May not be NULL. * @param src_len The length of the incoming buffer. */ -void md_ctx_update(md_ctx_t *ctx, const uint8_t *src, int src_len); +void md_ctx_update(md_ctx_t *ctx, const uint8_t *src, size_t src_len); /* * Output the message digest to the given buffer. diff --git a/src/openvpn/crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c index 076d4ee..2e328c3 100644 --- a/src/openvpn/crypto_mbedtls.c +++ b/src/openvpn/crypto_mbedtls.c @@ -765,6 +765,10 @@ return 1; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + /* * * Generic message digest information functions @@ -877,7 +881,7 @@ } void -md_ctx_update(mbedtls_md_context_t *ctx, const uint8_t *src, int src_len) +md_ctx_update(mbedtls_md_context_t *ctx, const uint8_t *src, size_t src_le= n) { ASSERT(0 =3D=3D mbedtls_md_update(ctx, src, src_len)); } @@ -994,6 +998,11 @@ seed_len, output, output_len)); } #else /* defined(HAVE_MBEDTLS_SSL_TLS_PRF) && defined(MBEDTLS_SSL_TLS_PRF_= TLS1) */ +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + /* * Generate the hash required by for the \c tls1_PRF function. * @@ -1122,10 +1131,10 @@ gc_free(&gc); return true; } -#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif +#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */ #endif /* ENABLE_CRYPTO_MBEDTLS */ diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index f596b8c..ec0269c 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -1165,7 +1165,7 @@ } void -md_ctx_update(EVP_MD_CTX *ctx, const uint8_t *src, int src_len) +md_ctx_update(EVP_MD_CTX *ctx, const uint8_t *src, size_t src_len) { EVP_DigestUpdate(ctx, src, src_len); } diff --git a/src/openvpn/httpdigest.c b/src/openvpn/httpdigest.c index f665b17..be20638 100644 --- a/src/openvpn/httpdigest.c +++ b/src/openvpn/httpdigest.c @@ -61,11 +61,6 @@ Hex[HASHHEXLEN] =3D '\0'; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - /* calculate H(A1) as per spec */ void DigestCalcHA1(IN char *pszAlg, IN char *pszUserName, IN char *pszRealm, IN= char *pszPassword, @@ -150,8 +145,4 @@ CvtHex(RespHash, Response); } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #endif /* if PROXY_DIGEST_AUTH */ diff --git a/src/openvpn/push.c b/src/openvpn/push.c index 2c717c7..6f146fc 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -772,6 +772,10 @@ return true; } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + void send_push_reply_auth_token(struct tls_multi *multi) { @@ -1046,7 +1050,7 @@ unsigned int *option_types_found, struct buffe= r *buf) { int ret =3D PUSH_MSG_ERROR; - const uint8_t ch =3D buf_read_u8(buf); + const int ch =3D buf_read_u8(buf); if (ch =3D=3D ',') { struct buffer buf_orig =3D (*buf); @@ -1090,10 +1094,6 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - int process_incoming_push_msg(struct context *c, const struct buffer *buffer, bool honor_received_options, unsigned int permis= sion_mask, -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1287?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: I27f2fcd903d26ccbfbd0cdc45f99cc3cd8b0e49a Gerrit-Change-Number: 1287 Gerrit-PatchSet: 3 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --WKTVayXhPIM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

crypto_backend: Change len argument of md_ctx_up=
date to size_t

The underlying APIs already use size_t and all theusers (only httpdigest and push) already put size_t
into it. So avoid c= onversion warnings.

Also fix one trivial conversion warning in push.= c
to able to easily remove the -Wconversion override
from the affecte= d code paths.

Change-Id: I27f2fcd903d26ccbfbd0cdc45f99cc3cd8b0e49aSigned-off-by: Frank Lichtenheld <frank@...2641...>
Acked-by: Ge= rt Doering <gert@...1296...>
Gerrit URL: https://gerrit.openvpn.ne= t/c/openvpn/+/1287
Message-Id: <20251028185706.1247-1-gert@...1296...= >
URL: https://www.mail-archive.com/openvpn-devel@...1223...= et/msg33973.html
Signed-off-by: Gert Doering <gert@...1296...>
= ---
M src/openvpn/crypto_backend.h
M src/openvpn/crypto_mbedtls.c
= M src/openvpn/crypto_openssl.c
M src/openvpn/httpdigest.c
M src/openv= pn/push.c
5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/openvpn/crypto_backend.h b/src/openvpn/crypto_backend.h=

index 4d6a96c..e95752a 100644
--- a/src/op= envpn/crypto_backend.h
+++ b/src/openvpn/crypto_backend.h
@@ -599,7 +599,7 @@
* @param src = Buffer to digest. May not be NULL.
* @param src_len = The length of the incoming buffer.
*/
-void md_ctx_update(md_ctx_t *ctx, const= uint8_t *src, int src_len);
+void md_ctx_update(md_ctx_t *ctx, const uint8_t *src, size_t src_l= en);

/*
* Output the m= essage digest to the given buffer.
diff --git a/src/openvpn= /crypto_mbedtls.c b/src/openvpn/crypto_mbedtls.c
index 076d= 4ee..2e328c3 100644
--- a/src/openvpn/crypto_mbedtls.c
+++ b/src/openvpn/crypto_mbedtls.c
@@ -765,6 +7= 65,10 @@
return 1;
}
=
+#if defined(__GNUC= __) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+=
/*
*
* Generic messag= e digest information functions
@@ -877,7 +881,7 @@ }

void
-md_ctx_update(mbedtls_md_context_t *ctx, const= uint8_t *src, int src_len)
+md_ctx_update(mbedtls_md_context_t *ctx, const uint8_t *src, size_t= src_len)
{
ASSERT(0 =3D=3D mbedtls_m= d_update(ctx, src, src_len));
}
@@ -994,6 = +998,11 @@
seed_len= , output, output_len));
}
#else /* define= d(HAVE_MBEDTLS_SSL_TLS_PRF) && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */=
+#if defined(__GNUC_= _) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"=
+#endif
+
/*
= * Generate the hash required by for the \c tls1_PRF function.
*

@@ -1122,10 +1131,10 @@
gc_free= (&gc);
return true;
}
<= span style=3D"color: hsl(0, 100%, 40%);">-#endif /* HAVE_MBEDTLS_SSL_TLS_PR= F && defined(MBEDTLS_SSL_TLS_PRF_TLS1) */

<= br> #if defined(__GNUC__) || defined(__clang__)
#pra= gma GCC diagnostic pop
#endif
+#endif /* HAVE_MBEDTLS_SSL_TLS_PRF && de= fined(MBEDTLS_SSL_TLS_PRF_TLS1) */

#endi= f /* ENABLE_CRYPTO_MBEDTLS */
diff --git a/src/openvpn/cryp= to_openssl.c b/src/openvpn/crypto_openssl.c
index f596b8c..= ec0269c 100644
--- a/src/openvpn/crypto_openssl.c+++ b/src/openvpn/crypto_openssl.c
@@ -1165,7 +1165,= 7 @@
}

void
<= span style=3D"color: hsl(0, 100%, 40%);">-md_ctx_update(EVP_MD_CTX *ctx, co= nst uint8_t *src, int src_len)
+md_ctx_update(EVP_MD_CTX *ctx, const uint8_t *src, size_t src_le= n)
{
EVP_DigestUpdate(ctx, src, src_l= en);
}
diff --git a/src/openvpn/httpdigest= .c b/src/openvpn/httpdigest.c
index f665b17..be20638 100644=
--- a/src/openvpn/httpdigest.c
+++ b/src/o= penvpn/httpdigest.c
@@ -61,11 +61,6 @@
= Hex[HASHHEXLEN] =3D '\0';
}

-#if defined(__GNUC__) || = defined(__clang__)
-#pr= agma GCC diagnostic push
-#endif
-
/* calculate H(A1) as per spec */
void
DigestCalcHA1(IN char *pszAlg, IN cha= r *pszUserName, IN char *pszRealm, IN char *pszPassword,
@@= -150,8 +145,4 @@
CvtHex(RespHash, Response); }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
#endif /* if PROXY_DIGEST_AUTH */
diff --git a/src/openvpn/push.c b/src/openvpn/push.c
= index 2c717c7..6f146fc 100644
--- a/src/openvpn/push.= c
+++ b/src/openvpn/push.c
@@ -772,6 +772,1= 0 @@
return true;
}
=
+#if defined(__GNUC_= _) || defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
+<= /span>
void
send_push_reply_auth_token(struct tl= s_multi *multi)
{
@@ -1046,7 +1050,7 @@
unsigned int *option_types_found= , struct buffer *buf)
{
int ret =3D P= USH_MSG_ERROR;
- con= st uint8_t ch =3D buf_read_u8(buf);
+ const int ch =3D buf_read_u8(buf);
= if (ch =3D=3D ',')
{
= struct buffer buf_orig =3D (*buf);
@@ -1090,10 +1094,6 @@<= /span>
return ret;
}

-#if defined(__GNUC__) || de= fined(__clang__)
-#prag= ma GCC diagnostic pop
-= #endif
-
int

process_incoming_push_msg(struct context *c, const = struct buffer *buffer,
bool hono= r_received_options, unsigned int permission_mask,

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

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I27f2fcd903d26ccbfbd0cdc45f9= 9cc3cd8b0e49a
Gerrit-Change-Number: 1287
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>
= --WKTVayXhPIM=--