From: "flichtenheld (Code Review)" Date: Thu, 6 Nov 2025 13:34:44 +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="otij2s7Dsfg="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: pkcs11_openssl: Silence a conversion warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --otij2s7Dsfg= 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/+/1352?usp=3Demail to review the following change. Change subject: pkcs11_openssl: Silence a conversion warning ...................................................................... pkcs11_openssl: Silence a conversion warning The only caller of this function uses a constant for this parameter, so this is all quite safe. Add an ASSERT for good measure anyway to make the assumption explicit. Change-Id: I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995 Signed-off-by: Frank Lichtenheld --- M src/openvpn/pkcs11_openssl.c 1 file changed, 2 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/52/1352/1 diff --git a/src/openvpn/pkcs11_openssl.c b/src/openvpn/pkcs11_openssl.c index f619b95..1d527db 100644 --- a/src/openvpn/pkcs11_openssl.c +++ b/src/openvpn/pkcs11_openssl.c @@ -428,18 +428,12 @@ return dn; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - int pkcs11_certificate_serial(pkcs11h_certificate_t certificate, char *serial,= size_t serial_len) { X509 *x509 =3D NULL; BIO *bio =3D NULL; int ret =3D 1; - int n; if ((x509 =3D pkcs11h_openssl_getX509(certificate)) =3D=3D NULL) { @@ -454,7 +448,8 @@ } i2a_ASN1_INTEGER(bio, X509_get_serialNumber(x509)); - n =3D BIO_read(bio, serial, serial_len - 1); + ASSERT(serial_len <=3D INT_MAX); + int n =3D BIO_read(bio, serial, (int)serial_len - 1); if (n < 0) { @@ -474,8 +469,4 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #endif /* defined(ENABLE_PKCS11) && defined(ENABLE_OPENSSL) */ -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1352?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6079bf9e7f6b37cb2e2d7f28851a77d0b08be995 Gerrit-Change-Number: 1352 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --otij2s7Dsfg= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

pkcs11_openssl: Silence a conversion warnin=
g

The only caller of this function uses a constant
for this param= eter, so this is all quite safe. Add
an ASSERT for good measure anyway t= o make the assumption
explicit.

Change-Id: I6079bf9e7f6b37cb2e2d7= f28851a77d0b08be995
Signed-off-by: Frank Lichtenheld <frank@...2723...= .>
---
M src/openvpn/pkcs11_openssl.c
1 file changed, 2 inserti= ons(+), 11 deletions(-)

git pull ssh://gerrit.op=
envpn.net:29418/openvpn refs/changes/52/1352/1
diff --git a/src/ope=
nvpn/pkcs11_openssl.c b/src/openvpn/pkcs11_openssl.c
index = f619b95..1d527db 100644
--- a/src/openvpn/pkcs11_openssl.c<= /span>
+++ b/src/openvpn/pkcs11_openssl.c
@@ -428,= 18 +428,12 @@
return dn;
}
=
-#if defined(__= GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
int
pkc= s11_certificate_serial(pkcs11h_certificate_t certificate, char *serial, siz= e_t serial_len)
{
X509 *x509 =3D NULL= ;
BIO *bio =3D NULL;
int ret =3D = 1;
- int n;
if ((x509 =3D pkcs11h_openssl_getX509(certif= icate)) =3D=3D NULL)
{
@@ -454,7 +448,= 8 @@
}

i2a_ASN1= _INTEGER(bio, X509_get_serialNumber(x509));
- n =3D BIO_read(bio, serial, serial_len - 1);
+ ASSERT(serial_len &l= t;=3D INT_MAX);
+ = int n =3D BIO_read(bio, serial, (int)serial_len - 1);

if (n < 0)
{
@@ -= 474,8 +469,4 @@
return ret;
}<= br>
-#if defined= (__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
= -
#endif /* defined(ENABLE_PKCS11) && defined(ENAB= LE_OPENSSL) */

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6079bf9e7f6b37cb2e2d7f28851= a77d0b08be995
Gerrit-Change-Number: 1352
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...>
= --otij2s7Dsfg=--