Skip to content

Commit ee2af66

Browse files
schwabecron2
authored andcommitted
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 <arne@rfc2549.org> Acked-by: Frank Lichtenheld <frank@lichtenheld.com> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1578 Message-Id: <20260322111131.8251-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36242.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent a84f8cf commit ee2af66

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/openvpn/crypto_openssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ crypto_clear_error(void)
229229
void
230230
crypto_print_openssl_errors(const unsigned int flags)
231231
{
232-
unsigned long err = 0;
232+
openssl_err_t err = 0;
233233
int line, errflags;
234234
const char *file, *data, *func;
235235

src/openvpn/openssl_compat.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
#include <openssl/x509.h>
4646
#include <openssl/err.h>
4747

48+
/* Define the type of error. This is something that is less
49+
* intrusive than casts everywhere */
50+
#if defined(OPENSSL_IS_AWSLC)
51+
typedef uint32_t openssl_err_t;
52+
#else
53+
typedef unsigned long openssl_err_t;
54+
#endif
55+
56+
4857
/* Functionality missing in 1.1.0 */
4958
#if OPENSSL_VERSION_NUMBER < 0x10101000L && !defined(ENABLE_CRYPTO_WOLFSSL)
5059
#define SSL_CTX_set1_groups SSL_CTX_set1_curves
@@ -157,12 +166,12 @@ EVP_MD_free(const EVP_MD *md)
157166
/* OpenSSL 1.1.1 and lower use only const EVP_MD, nothing to free */
158167
}
159168

160-
static inline unsigned long
169+
static inline openssl_err_t
161170
ERR_get_error_all(const char **file, int *line, const char **func, const char **data, int *flags)
162171
{
163172
static const char *empty = "";
164173
*func = empty;
165-
unsigned long err = ERR_get_error_line_data(file, line, data, flags);
174+
openssl_err_t err = ERR_get_error_line_data(file, line, data, flags);
166175
return err;
167176
}
168177

0 commit comments

Comments
 (0)