# HG changeset patch # User Richard Laager # Date 1191074064 0 # Node ID 5edb55b7010848252e0fa1602b22bc951c025c34 # Parent 62b83cebbb59ffe3b2c9413ce9e1c78544953ab8 applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971 through 54b7bcca130674c9f93777772bdf3d08237a7951 diff -r 62b83cebbb59 -r 5edb55b70108 libpurple/plugins/ssl/ssl-gnutls.c --- a/libpurple/plugins/ssl/ssl-gnutls.c Sat Sep 29 13:54:10 2007 +0000 +++ b/libpurple/plugins/ssl/ssl-gnutls.c Sat Sep 29 13:54:24 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 */