From 2b758382b644772579d4b6878f3ac39afc489cf2 Mon Sep 17 00:00:00 2001 From: Joerg Steffens Date: Mon, 24 Nov 2014 15:00:39 +0100 Subject: [PATCH] GnuTLS: use gnutls_transport_set_int if available gnutls_transport_set_ptr may cause problems on some platforms, therefore the replacement gnutls_transport_set_int is used when available (since GnuTLS >= 3.1.9). --- autoconf/configure.in | 4 ++++ src/lib/tls_gnutls.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/autoconf/configure.in b/autoconf/configure.in index 8a9ffdf545e..f2ca4024cb3 100644 --- a/autoconf/configure.in +++ b/autoconf/configure.in @@ -1275,6 +1275,10 @@ if test "x$support_crypto" != "xno" -o "x$support_tls" != "xno"; then if test "$have_gnutls" = "yes"; then AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if GNUTLS library is available]) + # gnutls_transport_set_ptr may cause problems on some platforms, + # therefore the replacement gnutls_transport_set_int is used + # when available (since GnuTLS >= 3.1.9) + AC_CHECK_FUNCS(gnutls_transport_set_int) fi if test "$support_tls" != "no" -a "$have_gnutls" = "yes"; then diff --git a/src/lib/tls_gnutls.c b/src/lib/tls_gnutls.c index cf19d69f51b..e741eca9730 100644 --- a/src/lib/tls_gnutls.c +++ b/src/lib/tls_gnutls.c @@ -490,8 +490,15 @@ TLS_CONNECTION *new_tls_connection(TLS_CONTEXT *ctx, int fd, bool server) /* * Link the TLS session and the filedescriptor of the socket used. + * gnutls_transport_set_ptr may cause problems on some platforms, + * therefore the replacement gnutls_transport_set_int is used, + * when available (since GnuTLS >= 3.1.9) */ +#ifdef HAVE_GNUTLS_TRANSPORT_SET_INT + gnutls_transport_set_int(tls->gnutls_state, fd); +#else gnutls_transport_set_ptr(tls->gnutls_state, (gnutls_transport_ptr_t)fd); +#endif /* * Server specific settings.