# HG changeset patch # User William Ehlhardt # Date 1191038474 0 # Node ID 60ba0f4d86a5635b6323642df09fad6937c977b2 # Parent 4711727df7361f5f8e774167e1a94d043265d20e - Apply pidgin-old-gnutls-bugfixes.patch from #3192 with slight modification. This compensates for an off-by-one error in old versions of GnuTLS. Thanks to Elliott Sales de Andrade. diff -r 4711727df736 -r 60ba0f4d86a5 libpurple/plugins/ssl/ssl-gnutls.c --- a/libpurple/plugins/ssl/ssl-gnutls.c Sat Sep 29 03:44:34 2007 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Sat Sep 29 04:01:14 2007 +0000 @@ -769,7 +769,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"); @@ -799,7 +802,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 " @@ -835,7 +841,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 */