From: "plaisthos (Code Review)" Date: Tue, 17 Mar 2026 13:32:11 +0000 References: Reply-To: 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="drc13MVPaeM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Use openssl_err_t typedef to deal with difference between TLS libraries List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openvpn-devel --drc13MVPaeM= 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/+/1578?usp=3Demail ) Change subject: Use openssl_err_t typedef to deal with difference between T= LS libraries ...................................................................... Use openssl_err_t typedef to deal with difference between TLS libraries AWS-LC and OpenSSL disagree on the type of that errors are reported in. Instead of having a lot of glue code and casting back and forth, use a typedef to always use the right type. Change-Id: I4adbdf0c8b82fd7de309aa5f6f3b0c8157c5ffe7 Signed-off-by: Arne Schwabe --- M src/openvpn/crypto_openssl.c M src/openvpn/openssl_compat.h 2 files changed, 12 insertions(+), 3 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/78/1578/1 diff --git a/src/openvpn/crypto_openssl.c b/src/openvpn/crypto_openssl.c index 19cb9a9..9900d06 100644 --- a/src/openvpn/crypto_openssl.c +++ b/src/openvpn/crypto_openssl.c @@ -229,7 +229,7 @@ void crypto_print_openssl_errors(const unsigned int flags) { - unsigned long err =3D 0; + openssl_err_t err =3D 0; int line, errflags; const char *file, *data, *func; diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_compat.h index ab011d3..8fdb39a 100644 --- a/src/openvpn/openssl_compat.h +++ b/src/openvpn/openssl_compat.h @@ -45,6 +45,15 @@ #include #include +/* Define the type of error. This is something that is less + * intrusive than casts everywhere */ +#if defined(OPENSSL_IS_AWSLC) +typedef uint32_t openssl_err_t; +#else +typedef unsigned long openssl_err_t; +#endif + + /* Functionality missing in 1.1.0 */ #if OPENSSL_VERSION_NUMBER < 0x10101000L && !defined(ENABLE_CRYPTO_WOLFSSL) #define SSL_CTX_set1_groups SSL_CTX_set1_curves @@ -157,12 +166,12 @@ /* OpenSSL 1.1.1 and lower use only const EVP_MD, nothing to free */ } -static inline unsigned long +static inline openssl_err_t ERR_get_error_all(const char **file, int *line, const char **func, const c= har **data, int *flags) { static const char *empty =3D ""; *func =3D empty; - unsigned long err =3D ERR_get_error_line_data(file, line, data, flags); + openssl_err_t err =3D ERR_get_error_line_data(file, line, data, flags); return err; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1578?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: I4adbdf0c8b82fd7de309aa5f6f3b0c8157c5ffe7 Gerrit-Change-Number: 1578 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-CC: openvpn-devel --drc13MVPaeM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

plaisthos has upl= oaded this change for review.

View Change

Use openssl_err_t typedef to deal with difference between TLS libraries=


AWS-LC and OpenSSL disagree on the type of that errors are reported= in.

Instead of having a lot of glue code and casting back and forth= , use a
typedef to always use the right type.

Change-Id: I4adbdf0= c8b82fd7de309aa5f6f3b0c8157c5ffe7
Signed-off-by: Arne Schwabe <arne@...220...= ..1227...>
---
M src/openvpn/crypto_openssl.c
M src/openvpn/ope= nssl_compat.h
2 files changed, 12 insertions(+), 3 deletions(-)

<= /pre>
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/cha=
nges/78/1578/1
diff --git a/src/openvpn/crypto_openssl.c b/src/open=
vpn/crypto_openssl.c
index 19cb9a9..9900d06 100644--- a/src/openvpn/crypto_openssl.c
+++ b/src/openvp= n/crypto_openssl.c
@@ -229,7 +229,7 @@
voi= d
crypto_print_openssl_errors(const unsigned int flags)
{
- u= nsigned long err =3D 0;
+ openssl_err_t err =3D 0;
int line, errflags;
const char *file, *data, *func;

diff --git a/src/openvpn/openssl_compat.h b/src/openvpn/openssl_= compat.h
index ab011d3..8fdb39a 100644
--- = a/src/openvpn/openssl_compat.h
+++ b/src/openvpn/openssl_co= mpat.h
@@ -45,6 +45,15 @@
#include <ope= nssl/x509.h>
#include <openssl/err.h>
<= span>

+/* Define the= type of error. This is something that is less
+ * intrusive than casts everywhere */
= +#if defined(OPENSSL_IS_AWSLC)<= /span>
+typedef uint32_t ope= nssl_err_t;
+#else
+typedef unsigned long = openssl_err_t;
+#endi= f
+
+
/* Functionality mi= ssing in 1.1.0 */
#if OPENSSL_VERSION_NUMBER < 0x101010= 00L && !defined(ENABLE_CRYPTO_WOLFSSL)
#define SSL= _CTX_set1_groups SSL_CTX_set1_curves
@@ -157,12 +166,12 @@<= /span>
/* OpenSSL 1.1.1 and lower use only const EVP_MD, noth= ing to free */
}

-static inline unsigned long
+static inline openssl_err_t
<= br> ERR_get_error_all(const char **file, int *line, const char **func= , const char **data, int *flags)
{
st= atic const char *empty =3D "";
*func =3D emp= ty;
- unsigned long = err =3D ERR_get_error_line_data(file, line, data, flags);
+ openssl_err_t err =3D ERR_get_err= or_line_data(file, line, data, flags);
return err;
}


To vi= ew, visit change 1578. To unsubscribe, or for help writing mail filters, visit = settings.

=
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4adbdf0c8b82fd7de309aa5f6f3= b0c8157c5ffe7
Gerrit-Change-Number: 1578
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --drc13MVPaeM=--