Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix compilation on GnuTLS prior to 3.5.0
The macro gnutls_check_version_numeric, used in
b974ed3, wasn't added until GnuTLS 3.5.0
(and was in fact based on the gtls_ver macro from openconnect)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
  • Loading branch information
dlenski committed Apr 4, 2020
1 parent b974ed3 commit efc2c4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 0 additions & 10 deletions gnutls.c
Expand Up @@ -65,16 +65,6 @@ static int gnutls_pin_callback(void *priv, int attempt, const char *uri,
#define GNUTLS_FORCE_CLIENT_CERT 0
#endif

/* Compile-time optimisable GnuTLS version check. We should never be
* run against a version of GnuTLS which is *older* than the one we
* were built again, but we might be run against a version which is
* newer. So some ancient compatibility code *can* be dropped at
* compile time. Likewise, if building against GnuTLS 2.x then we
* can never be running agsinst a 3.x library — the soname changed. */
#define gtls_ver(a,b,c) ( GNUTLS_VERSION_MAJOR >= (a) && \
(GNUTLS_VERSION_NUMBER >= ( ((a) << 16) + ((b) << 8) + (c) ) || \
gnutls_check_version(#a "." #b "." #c)))

static char tls_library_version[32] = "";

const char *openconnect_get_tls_library_version()
Expand Down
16 changes: 16 additions & 0 deletions gnutls.h
Expand Up @@ -56,4 +56,20 @@ int oc_gnutls_encode_rs_value(gnutls_datum_t *sig_value, const gnutls_datum_t *r

char *get_gnutls_cipher(gnutls_session_t session);

/* Compile-time optimisable GnuTLS version check. We should never be
* run against a version of GnuTLS which is *older* than the one we
* were built again, but we might be run against a version which is
* newer. So some ancient compatibility code *can* be dropped at
* compile time. Likewise, if building against GnuTLS 2.x then we
* can never be running agsinst a 3.x library — the soname changed.
*
* This macro was added upstream, gnutls_check_version_numeric,
* in 3.5.0 (see https://gitlab.com/gnutls/gnutls/commit/c8b40aeb) */
#define gtls_ver(a,b,c) ( GNUTLS_VERSION_MAJOR >= (a) && \
(GNUTLS_VERSION_NUMBER >= ( ((a) << 16) + ((b) << 8) + (c) ) || \
gnutls_check_version(#a "." #b "." #c)))
#ifndef gnutls_check_version_numeric
#define gnutls_check_version_numeric gtls_ver
#endif

#endif /* __OPENCONNECT_GNUTLS_H__ */

0 comments on commit efc2c4a

Please sign in to comment.