From: "plaisthos (Code Review)" Date: Tue, 14 Apr 2026 12:11:51 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <575692006c6ac31549bdf8414c3bc8439c745940-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="J2r5rxavWcM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: AWS-LC: Use openssl_stack_size_t for declaring stack size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openvpn-devel --J2r5rxavWcM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/= c/openvpn/+/1627?usp=3Demail ) Change subject: AWS-LC: Use openssl_stack_size_t for declaring stack size ...................................................................... AWS-LC: Use openssl_stack_size_t for declaring stack size OpenSSL and AWS-LC disagree on the type that they use for stack size. Instead of doing a lot of various casts, use a typedef to avoid these casts and use the right type for each library. Change-Id: Ifd29485524674c64d56fc5f7ef8bdd1e00215fc9 Signed-off-by: Arne Schwabe --- M src/openvpn/openssl_compat.h M src/openvpn/ssl_openssl.c M src/openvpn/ssl_verify_openssl.c 3 files changed, 17 insertions(+), 16 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/27/1627/1 diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index 8fdb39a..757e45d 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -49,8 +49,12 @@ * intrusive than casts everywhere */ #if defined(OPENSSL_IS_AWSLC) typedef uint32_t openssl_err_t; +typedef size_t openssl_stack_size_t; +#define PRI_OPENSSL_STACK "zu" #else typedef unsigned long openssl_err_t; +typedef int openssl_stack_size_t; +#define PRI_OPENSSL_STACK "d" #endif diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c index fd05f43..aaf57a8 100644 --- a/src/openvpn/ssl_openssl.c +++ b/src/openvpn/ssl_openssl.c @@ -907,7 +907,6 @@ X509 *cert; STACK_OF(X509) *ca =3D NULL; PKCS12 *p12; - int i; char password[256]; ASSERT(NULL !=3D ctx); @@ -991,7 +990,7 @@ */ if (ca && sk_X509_num(ca)) { - for (i =3D 0; i < sk_X509_num(ca); i++) + for (openssl_stack_size_t i =3D 0; i < sk_X509_num(ca); i++) { X509_STORE *cert_store =3D SSL_CTX_get_cert_store(ctx->ctx= ); if (!X509_STORE_add_cert(cert_store, sk_X509_value(ca, i))) @@ -1016,7 +1015,7 @@ */ if (ca && sk_X509_num(ca)) { - for (i =3D 0; i < sk_X509_num(ca); i++) + for (openssl_stack_size_t i =3D 0; i < sk_X509_num(ca); i++) { if (!SSL_CTX_add_extra_chain_cert(ctx->ctx, sk_X509_value(= ca, i))) { @@ -1790,7 +1789,7 @@ X509_LOOKUP *lookup =3D NULL; X509_STORE *store =3D NULL; BIO *in =3D NULL; - int i, added =3D 0, prev =3D 0; + openssl_stack_size_t added =3D 0, prev =3D 0; ASSERT(NULL !=3D ctx); @@ -1819,7 +1818,7 @@ if (info_stack) { - for (i =3D 0; i < sk_X509_INFO_num(info_stack); i++) + for (openssl_stack_size_t i =3D 0; i < sk_X509_INFO_num(info_s= tack); i++) { X509_INFO *info =3D sk_X509_INFO_value(info_stack, i); if (info->crl) @@ -1877,11 +1876,11 @@ if (tls_server) { - int cnum =3D sk_X509_NAME_num(cert_names); + openssl_stack_size_t cnum =3D sk_X509_NAME_num(cert_na= mes); if (cnum !=3D (prev + 1)) { crypto_msg(M_WARN, - "Cannot load CA certificate file %s (en= try %d did not validate)", + "Cannot load CA certificate file %s (en= try %" PRI_OPENSSL_STACK " did not validate)", print_key_filename(ca_file, ca_file_inl= ine), added); } prev =3D cnum; @@ -1889,7 +1888,7 @@ } sk_X509_INFO_pop_free(info_stack, X509_INFO_free); } - int cnum; + openssl_stack_size_t cnum; if (tls_server) { cnum =3D sk_X509_NAME_num(cert_names); @@ -1907,8 +1906,8 @@ if (cnum !=3D added) { crypto_msg(M_FATAL, - "Cannot load CA certificate file %s (only %d " - "of %d entries were valid X509 names)", + "Cannot load CA certificate file %s (only %" PR= I_OPENSSL_STACK + "of %" PRI_OPENSSL_STACK "entries were valid X5= 09 names)", print_key_filename(ca_file, ca_file_inline), cn= um, added); } } @@ -2557,7 +2556,7 @@ #else STACK_OF(SSL_CIPHER) *sk =3D SSL_get1_supported_ciphers(ssl); #endif - for (int i =3D 0; i < sk_SSL_CIPHER_num(sk); i++) + for (openssl_stack_size_t i =3D 0; i < sk_SSL_CIPHER_num(sk); i++) { const SSL_CIPHER *c =3D sk_SSL_CIPHER_value(sk, i); diff --git a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_open= ssl.c index 115b8d2..af19459 100644 --- a/src/openvpn/ssl_verify_openssl.c +++ b/src/openvpn/ssl_verify_openssl.c @@ -138,10 +138,10 @@ * one, but we don't depend on it... */ - int numalts =3D sk_GENERAL_NAME_num(extensions); + openssl_stack_size_t numalts =3D sk_GENERAL_NAME_num(extensions); /* loop through all alternatives */ - for (int i =3D 0; i < numalts; i++) + for (openssl_stack_size_t i =3D 0; i < numalts; i++) { /* get a handle to alternative name number i */ const GENERAL_NAME *name =3D sk_GENERAL_NAME_value(extensions,= i); @@ -763,10 +763,8 @@ } else { - int i; - msg(D_HANDSHAKE, "Validating certificate extended key usage"); - for (i =3D 0; SUCCESS !=3D fFound && i < sk_ASN1_OBJECT_num(eku); = i++) + for (openssl_stack_size_t i =3D 0; SUCCESS !=3D fFound && i < sk_A= SN1_OBJECT_num(eku); i++) { ASN1_OBJECT *oid =3D sk_ASN1_OBJECT_value(eku, i); char szOid[1024]; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1627?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: Ifd29485524674c64d56fc5f7ef8bdd1e00215fc9 Gerrit-Change-Number: 1627 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-CC: openvpn-devel --J2r5rxavWcM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

plaisthos has upl= oaded this change for review.

View Change

AWS-LC: Use openssl_stack_size_t for declaring stack size

OpenSS= L and AWS-LC disagree on the type that they use for
stack size. Instead = of doing a lot of various casts, use
a typedef to avoid these casts and = use the right type for
each library.

Change-Id: Ifd29485524674c64= d56fc5f7ef8bdd1e00215fc9
Signed-off-by: Arne Schwabe <arne@...1227...= >
---
M src/openvpn/openssl_compat.h
M src/openvpn/ssl_openssl.= c
M src/openvpn/ssl_verify_openssl.c
3 files changed, 17 insertions(+= ), 16 deletions(-)

git pull ssh://gerrit.openvpn=
.net:29418/openvpn refs/changes/27/1627/1
diff --git a/src/openvpn/=
openssl_compat.h b/src/openvpn/openssl_compat.h
index 8fdb3= 9a..757e45d 100644
--- a/src/openvpn/openssl_compat.h
+++ b/src/openvpn/openssl_compat.h
@@ -49,8 +49,= 12 @@
* intrusive than casts everywhere */
#if defined(OPENSSL_IS_AWSLC)

typedef uint32_t openssl_= err_t;
+typedef size_= t openssl_stack_size_t;
+#define PRI_OPENSSL_STACK "zu"
#else<= br> typedef unsigned long openssl_err_t;
+typedef int openssl_stack_size_t;
+#define PRI_OPENSSL_STACK "d&= quot;
#endif

diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index fd05f43..aaf57a8 100644
--- a/src/open= vpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c@@ -907,7 +907,6 @@
X509 *cert;
STACK_OF(X509) *ca =3D NULL;

PKCS12 *p12;=
- int i;
= char password[256];

ASSERT(NULL = !=3D ctx);
@@ -991,7 +990,7 @@
*/=
if (ca && sk_X509_num(ca))
{
- = for (i =3D 0; i < sk_X509_num(ca); i++)
+ for (openssl_stack_size_t i =3D 0; i = < sk_X509_num(ca); i++)
{
= X509_STORE *cert_store =3D SSL_CTX_get_cert_store(ctx->c= tx);
if (!X509_STORE_add_cert(cert_store, = sk_X509_value(ca, i)))
@@ -1016,7 +1015,7 @@
*/
if (ca && sk_X509_num(ca))<= /span>
{
- for (i =3D 0; i < sk_X509_num(ca); i++)
+ for (openssl_stack_size= _t i =3D 0; i < sk_X509_num(ca); i++)

{
if (!SSL_CTX_add_extra_chain_cert(ctx->ctx= , sk_X509_value(ca, i)))
{
@@ -1790,7 +1789,7 @@

X509_LOOKUP *lookup =3D NULL;
X509_STORE *store =3D NULL;
BIO *i= n =3D NULL;
- int i,= added =3D 0, prev =3D 0;
+ openssl_stack_size_t added =3D 0, prev =3D 0;

ASSERT(NULL !=3D ctx);

@@ -1819,7 +1818,7 @@


if (info= _stack)
{
- for (i =3D 0; i < sk_X509_INFO_num(info_stack);= i++)
+ fo= r (openssl_stack_size_t i =3D 0; i < sk_X509_INFO_num(info_stack); i++)<= /span>
{
X509_INFO *= info =3D sk_X509_INFO_value(info_stack, i);
= if (info->crl)
@@ -1877,11 +1876,11 @@

if (tls_server)
= {
- = int cnum =3D sk_X509_NAME_num(cert_names);
+ openssl_stack_size_t = cnum =3D sk_X509_NAME_num(cert_names);
= if (cnum !=3D (prev + 1))
{ crypto_msg(M_WARN,
- "Canno= t load CA certificate file %s (entry %d did not validate)",
= + = "Cannot load CA certificate file %s (entry %" PRI_OPENSSL_ST= ACK " did not validate)",
= print_key_filename(ca_file, ca_file_inline), added); }
prev =3D= cnum;
@@ -1889,7 +1888,7 @@
}=
sk_X509_INFO_pop_free(info_stack, X509_INFO_f= ree);
}
- int cnum;
+ openssl_stack_size_t cnum;
if (tl= s_server)
{
cnum =3D = sk_X509_NAME_num(cert_names);
@@ -1907,8 +1906,8 @@<= br> if (cnum !=3D added)
{
crypto_msg(M_FATAL,
- "Cannot loa= d CA certificate file %s (only %d "
- "of %d entries were vali= d X509 names)",
= + "Cannot load CA certificate file %s (only = %" PRI_OPENSSL_STACK
+ "of %" PRI_OPENSSL_STACK "e= ntries were valid X509 names)",
= print_key_filename(ca_file, ca_file_inline), cnum, added);
= }
}
@@ -2557,7 = +2556,7 @@
#else
STACK_OF(SSL_CIPHER)= *sk =3D SSL_get1_supported_ciphers(ssl);
#endif- for (int i =3D 0; i < sk= _SSL_CIPHER_num(sk); i++)
+ for (openssl_stack_size_t i =3D 0; i < sk_SSL_CIPHER_num(sk); = i++)
{
const SSL_CIPHER *c = =3D sk_SSL_CIPHER_value(sk, i);

diff --gi= t a/src/openvpn/ssl_verify_openssl.c b/src/openvpn/ssl_verify_openssl.c
index 115b8d2..af19459 100644
--- a/src/openvp= n/ssl_verify_openssl.c
+++ b/src/openvpn/ssl_verify_openssl= .c
@@ -138,10 +138,10 @@
* one, b= ut we don't depend on it...
*/

- int numalt= s =3D sk_GENERAL_NAME_num(extensions);
+ openssl_stack_size_t numalts =3D sk_GENERAL_NAME= _num(extensions);

/* loop throug= h all alternatives */
-= for (int i =3D 0; i < numalts; i++)
+ for (openssl_stack_size_t i =3D 0; i <= ; numalts; i++)
{
/* = get a handle to alternative name number i */
c= onst GENERAL_NAME *name =3D sk_GENERAL_NAME_value(extensions, i);@@ -763,10 +763,8 @@
}
els= e
{
-
msg(D_HANDSHAKE, "Validating certificate extende= d key usage");
- = for (i =3D 0; SUCCESS !=3D fFound && i < sk_ASN1_OBJECT_nu= m(eku); i++)
+ = for (openssl_stack_size_t i =3D 0; SUCCESS !=3D fFound && i < s= k_ASN1_OBJECT_num(eku); i++)
{
= ASN1_OBJECT *oid =3D sk_ASN1_OBJECT_value(eku, i);
char szOid[1024];


To vie= w, visit change 1627. To unsubscribe, or for help writing mail filters, visit <= a href=3D"http://gerrit.openvpn.net/settings?usp=3Demail">settings.

=
<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifd29485524674c64d56fc5f7ef8= bdd1e00215fc9
Gerrit-Change-Number: 1627
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --J2r5rxavWcM=--