From: Kevin McCarthy Date: Wed, 28 Jan 2015 00:15:31 +0000 (-0800) Subject: Clean up gnutls warnings. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b85683a57db2f32cb6bb67ed9e0ded5047e8933;p=mutt Clean up gnutls warnings. Most of the warning were caused by deprecated types: gnutls_certificate_credentials gnutls_certificate_status gnutls_datum gnutls_digest_algorithm gnutls_session gnutls_transport_ptr gnutls_x509_crt Even though I believe the replacements have been around for a while, the patch adds autoconf checks and fallback typedefs. One warning was caused by casting an int to a pointer for the second parameter to gnutls_transport_set_ptr(). Recent gnutls has a replacement gnutls_transport_set_int() macro, but this macro simply (eventually) casts the parameter using "(gnutls_transport_ptr_t)(long)". So this patch just does the same. --- diff --git a/configure.ac b/configure.ac index 324c7584..09aef1ca 100644 --- a/configure.ac +++ b/configure.ac @@ -709,6 +709,13 @@ then LIBS="$LIBS -lgnutls" AC_CHECK_FUNCS(gnutls_priority_set_direct) + AC_CHECK_TYPES([gnutls_certificate_credentials_t, + gnutls_certificate_status_t, + gnutls_datum_t, + gnutls_digest_algorithm_t, + gnutls_session_t, + gnutls_transport_ptr_t, + gnutls_x509_crt_t], [], [], [[#include ]]) LIBS="$saved_LIBS" MUTTLIBS="$MUTTLIBS -lgnutls" diff --git a/mutt_ssl_gnutls.c b/mutt_ssl_gnutls.c index 3ff879be..bdfcbea8 100644 --- a/mutt_ssl_gnutls.c +++ b/mutt_ssl_gnutls.c @@ -43,10 +43,41 @@ #define CERTERR_SIGNERNOTCA 32 #define CERTERR_INSECUREALG 64 +/* deprecated types compatibility */ + +#ifndef HAVE_GNUTLS_CERTIFICATE_CREDENTIALS_T +typedef gnutls_certificate_credentials gnutls_certificate_credentials_t; +#endif + +#ifndef HAVE_GNUTLS_CERTIFICATE_STATUS_T +typedef gnutls_certificate_status gnutls_certificate_status_t; +#endif + +#ifndef HAVE_GNUTLS_DATUM_T +typedef gnutls_datum gnutls_datum_t; +#endif + +#ifndef HAVE_GNUTLS_DIGEST_ALGORITHM_T +typedef gnutls_digest_algorithm gnutls_digest_algorithm_t; +#endif + +#ifndef HAVE_GNUTLS_SESSION_T +typedef gnutls_session gnutls_session_t; +#endif + +#ifndef HAVE_GNUTLS_TRANSPORT_PTR_T +typedef gnutls_transport_ptr gnutls_transport_ptr_t; +#endif + +#ifndef HAVE_GNUTLS_X509_CRT_T +typedef gnutls_x509_crt gnutls_x509_crt_t; +#endif + + typedef struct _tlssockdata { - gnutls_session state; - gnutls_certificate_credentials xcred; + gnutls_session_t state; + gnutls_certificate_credentials_t xcred; } tlssockdata; @@ -368,7 +399,7 @@ static int tls_negotiate (CONNECTION * conn) } /* set socket */ - gnutls_transport_set_ptr (data->state, (gnutls_transport_ptr)conn->fd); + gnutls_transport_set_ptr (data->state, (gnutls_transport_ptr_t)(long)conn->fd); if (tls_set_priority(data) < 0) { goto fail; @@ -470,13 +501,13 @@ static int tls_starttls_close (CONNECTION* conn) #define CERT_SEP "-----BEGIN" /* this bit is based on read_ca_file() in gnutls */ -static int tls_compare_certificates (const gnutls_datum *peercert) +static int tls_compare_certificates (const gnutls_datum_t *peercert) { - gnutls_datum cert; + gnutls_datum_t cert; unsigned char *ptr; FILE *fd1; int ret; - gnutls_datum b64_data; + gnutls_datum_t b64_data; unsigned char *b64_data_data; struct stat filestat; @@ -537,8 +568,8 @@ static int tls_compare_certificates (const gnutls_datum *peercert) return 0; } -static void tls_fingerprint (gnutls_digest_algorithm algo, - char* s, int l, const gnutls_datum* data) +static void tls_fingerprint (gnutls_digest_algorithm_t algo, + char* s, int l, const gnutls_datum_t* data) { unsigned char md[36]; size_t n; @@ -576,7 +607,7 @@ static char *tls_make_date (time_t t, char *s, size_t len) return (s); } -static int tls_check_stored_hostname (const gnutls_datum *cert, +static int tls_check_stored_hostname (const gnutls_datum_t *cert, const char *hostname) { char buf[80]; @@ -627,11 +658,11 @@ static int tls_check_stored_hostname (const gnutls_datum *cert, } static int tls_check_preauth (const gnutls_datum_t *certdata, - gnutls_certificate_status certstat, + gnutls_certificate_status_t certstat, const char *hostname, int chainidx, int* certerr, int* savedcert) { - gnutls_x509_crt cert; + gnutls_x509_crt_t cert; *certerr = CERTERR_VALID; *savedcert = 0; @@ -748,11 +779,11 @@ static int tls_check_preauth (const gnutls_datum_t *certdata, * Returns 0 on failure, nonzero on success. */ static int tls_check_one_certificate (const gnutls_datum_t *certdata, - gnutls_certificate_status certstat, + gnutls_certificate_status_t certstat, const char* hostname, int idx, int len) { int certerr, savedcert; - gnutls_x509_crt cert; + gnutls_x509_crt_t cert; char buf[SHORT_STRING]; char fpbuf[SHORT_STRING]; size_t buflen; @@ -769,7 +800,7 @@ static int tls_check_one_certificate (const gnutls_datum_t *certdata, char helpstr[LONG_STRING]; char title[STRING]; FILE *fp; - gnutls_datum pemdata; + gnutls_datum_t pemdata; int i, row, done, ret; if (!tls_check_preauth (certdata, certstat, hostname, idx, &certerr, @@ -1018,7 +1049,7 @@ static int tls_check_one_certificate (const gnutls_datum_t *certdata, } /* sanity-checking wrapper for gnutls_certificate_verify_peers */ -static gnutls_certificate_status tls_verify_peers (gnutls_session tlsstate) +static gnutls_certificate_status_t tls_verify_peers (gnutls_session_t tlsstate) { int verify_ret; unsigned int status; @@ -1055,10 +1086,10 @@ static gnutls_certificate_status tls_verify_peers (gnutls_session tlsstate) static int tls_check_certificate (CONNECTION* conn) { tlssockdata *data = conn->sockdata; - gnutls_session state = data->state; - const gnutls_datum *cert_list; + gnutls_session_t state = data->state; + const gnutls_datum_t *cert_list; unsigned int cert_list_size = 0; - gnutls_certificate_status certstat; + gnutls_certificate_status_t certstat; int certerr, i, preauthrc, savedcert, rc = 0; int rcpeer = -1; /* the result of tls_check_preauth() on the peer's EE cert */