From 76d5098363019ec2c5a9b0f584c78a15a92e3bab Mon Sep 17 00:00:00 2001 From: Phil Pennock Date: Mon, 21 May 2012 05:54:50 -0400 Subject: [PATCH] avoid NUL in dh params file gnutls_dh_params_export_pkcs3() returns 2 different sizes. NUL observed by Janne Snabb --- src/src/tls-gnu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/src/tls-gnu.c b/src/src/tls-gnu.c index 3ea02bd52..0ac72ad25 100644 --- a/src/src/tls-gnu.c +++ b/src/src/tls-gnu.c @@ -512,8 +512,9 @@ if (rc < 0) m.data = malloc(m.size); if (m.data == NULL) return tls_error(US"memory allocation failed", strerror(errno), NULL); + /* this will return a size 1 less than the allocation size above */ rc = gnutls_dh_params_export_pkcs3(dh_server_params, GNUTLS_X509_FMT_PEM, - m.data, &sz); + m.data, &m.size); if (rc != GNUTLS_E_SUCCESS) { free(m.data); -- 2.25.1