changeset 20283:5edb55b70108

applied changes from 38a516984dfbc8fb0def05acb69fc1180ec0b971 through 54b7bcca130674c9f93777772bdf3d08237a7951
author Richard Laager <rlaager@wiktel.com>
date Sat, 29 Sep 2007 13:54:24 +0000
parents 62b83cebbb59
children f0a44de156fc
files libpurple/plugins/ssl/ssl-gnutls.c
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 */