Mercurial > pidgin
changeset 20705:3e85d985d9f0
merge of '27d49044df2da785a519726b37211c6c5218bc41'
and '6a82d40bc7eedd0f5990f952ce1cfc7d194eabdb'
author | William Ehlhardt <williamehlhardt@gmail.com> |
---|---|
date | Sat, 29 Sep 2007 04:59:50 +0000 |
parents | d6fb31898506 (diff) 8a830c4ce996 (current diff) |
children | 370cb5fd5586 |
files | |
diffstat | 1 files changed, 32 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/plugins/ssl/ssl-gnutls.c Sat Sep 29 02:50:14 2007 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Sat Sep 29 04:59:50 2007 +0000 @@ -163,9 +163,9 @@ g_list_free(peers); { - const gnutls_datum_t *cert_list; + const gnutls_datum *cert_list; unsigned int cert_list_size = 0; - gnutls_session_t session=gnutls_data->session; + gnutls_session session=gnutls_data->session; int i; cert_list = @@ -182,7 +182,7 @@ gchar tbuf[256]; gsize tsz=sizeof(tbuf); gchar * tasc = NULL; - gnutls_x509_crt_t cert; + gnutls_x509_crt cert; gnutls_x509_crt_init(&cert); gnutls_x509_crt_import (cert, &cert_list[i], @@ -365,7 +365,7 @@ /* Forward declarations are fun! */ static PurpleCertificate * -x509_import_from_datum(const gnutls_datum_t dt, gnutls_x509_crt_fmt_t mode); +x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode); static GList * ssl_gnutls_get_peer_certificates(PurpleSslConnection * gsc) @@ -376,7 +376,7 @@ GList * peer_certs = NULL; /* List of raw certificates as given by GnuTLS */ - const gnutls_datum_t *cert_list; + const gnutls_datum *cert_list; unsigned int cert_list_size = 0; unsigned int i; @@ -414,7 +414,7 @@ /** Refcounted GnuTLS certificate data instance */ typedef struct { gint refcount; - gnutls_x509_crt_t crt; + gnutls_x509_crt crt; } x509_crtdata_t; /** Helper functions for reference counting */ @@ -446,7 +446,7 @@ /** Helper macro to retrieve the GnuTLS crt_t from a PurpleCertificate */ #define X509_GET_GNUTLS_DATA(pcrt) ( ((x509_crtdata_t *) (pcrt->data))->crt) -/** Transforms a gnutls_datum_t containing an X.509 certificate into a Certificate instance under the x509_gnutls scheme +/** Transforms a gnutls_datum containing an X.509 certificate into a Certificate instance under the x509_gnutls scheme * * @param dt Datum to transform * @param mode GnuTLS certificate format specifier (GNUTLS_X509_FMT_PEM for @@ -456,7 +456,7 @@ * @return A newly allocated Certificate structure of the x509_gnutls scheme */ static PurpleCertificate * -x509_import_from_datum(const gnutls_datum_t dt, gnutls_x509_crt_fmt_t mode) +x509_import_from_datum(const gnutls_datum dt, gnutls_x509_crt_fmt mode) { /* Internal certificate data structure */ x509_crtdata_t *certdat; @@ -491,7 +491,7 @@ PurpleCertificate *crt; /* Certificate being constructed */ gchar *buf; /* Used to load the raw file data */ gsize buf_sz; /* Size of the above */ - gnutls_datum_t dt; /* Struct to pass down to GnuTLS */ + gnutls_datum dt; /* Struct to pass down to GnuTLS */ purple_debug_info("gnutls", "Attempting to load X.509 certificate from %s\n", @@ -532,7 +532,7 @@ static gboolean x509_export_certificate(const gchar *filename, PurpleCertificate *crt) { - gnutls_x509_crt_t crt_dat; /* GnuTLS cert struct */ + gnutls_x509_crt crt_dat; /* GnuTLS cert struct */ int ret; gchar * out_buf; /* Data to output */ size_t out_size; /* Output size */ @@ -639,8 +639,8 @@ x509_certificate_signed_by(PurpleCertificate * crt, PurpleCertificate * issuer) { - gnutls_x509_crt_t crt_dat; - gnutls_x509_crt_t issuer_dat; + gnutls_x509_crt crt_dat; + gnutls_x509_crt issuer_dat; unsigned int verify; /* used to store result from GnuTLS verifier */ int ret; @@ -673,10 +673,8 @@ purple_debug_info("gnutls/x509", "Certificate for %s claims to be " "issued by %s, but the certificate " - "for %s does not match. A strcmp " - "says %d\n", - crt_id, crt_issuer_id, issuer_id, - strcmp(crt_issuer_id, issuer_id)); + "for %s does not match.\n", + crt_id, crt_issuer_id, issuer_id); g_free(crt_id); g_free(issuer_id); g_free(crt_issuer_id); @@ -726,7 +724,7 @@ { size_t hashlen = 20; /* SHA1 hashes are 20 bytes */ size_t tmpsz = hashlen; /* Throw-away variable for GnuTLS to stomp on*/ - gnutls_x509_crt_t crt_dat; + gnutls_x509_crt crt_dat; GByteArray *hash; /**< Final hash container */ guchar hashbuf[hashlen]; /**< Temporary buffer to contain hash */ @@ -753,7 +751,7 @@ static gchar * x509_cert_dn (PurpleCertificate *crt) { - gnutls_x509_crt_t cert_dat; + gnutls_x509_crt cert_dat; gchar *dn = NULL; size_t dn_size; @@ -769,7 +767,10 @@ gnutls_x509_crt_get_dn(cert_dat, dn, &dn_size); /* Now allocate and get the Distinguished Name */ - dn = g_new0(gchar, dn_size); + /* Old versions of GnuTLS have an off-by-one error in reporting + the size of the needed buffer in some functions, so allocate + an extra byte */ + dn = g_new0(gchar, ++dn_size); if (0 != gnutls_x509_crt_get_dn(cert_dat, dn, &dn_size)) { purple_debug_error("gnutls/x509", "Failed to get Distinguished Name\n"); @@ -783,7 +784,7 @@ static gchar * x509_issuer_dn (PurpleCertificate *crt) { - gnutls_x509_crt_t cert_dat; + gnutls_x509_crt cert_dat; gchar *dn = NULL; size_t dn_size; @@ -799,7 +800,10 @@ gnutls_x509_crt_get_issuer_dn(cert_dat, dn, &dn_size); /* Now allocate and get the Distinguished Name */ - dn = g_new0(gchar, dn_size); + /* Old versions of GnuTLS have an off-by-one error in reporting + the size of the needed buffer in some functions, so allocate + an extra byte */ + dn = g_new0(gchar, ++dn_size); if (0 != gnutls_x509_crt_get_issuer_dn(cert_dat, dn, &dn_size)) { purple_debug_error("gnutls/x509", "Failed to get issuer's Distinguished " @@ -814,7 +818,7 @@ static gchar * x509_common_name (PurpleCertificate *crt) { - gnutls_x509_crt_t cert_dat; + gnutls_x509_crt cert_dat; gchar *cn = NULL; size_t cn_size; int ret; @@ -835,7 +839,10 @@ cn, &cn_size); /* Now allocate and get the Common Name */ - cn = g_new0(gchar, cn_size); + /* Old versions of GnuTLS have an off-by-one error in reporting + the size of the needed buffer in some functions, so allocate + an extra byte */ + cn = g_new0(gchar, ++cn_size); ret = gnutls_x509_crt_get_dn_by_oid(cert_dat, GNUTLS_OID_X520_COMMON_NAME, 0, /* First CN found, please */ @@ -854,7 +861,7 @@ static gboolean x509_check_name (PurpleCertificate *crt, const gchar *name) { - gnutls_x509_crt_t crt_dat; + gnutls_x509_crt crt_dat; g_return_val_if_fail(crt, FALSE); g_return_val_if_fail(crt->scheme == &x509_gnutls, FALSE); @@ -872,7 +879,7 @@ static gboolean x509_times (PurpleCertificate *crt, time_t *activation, time_t *expiration) { - gnutls_x509_crt_t crt_dat; + gnutls_x509_crt crt_dat; /* GnuTLS time functions return this on error */ const time_t errval = (time_t) (-1);