avoid NUL in dh params file
authorPhil Pennock <pdp@exim.org>
Mon, 21 May 2012 09:54:50 +0000 (05:54 -0400)
committerPhil Pennock <pdp@exim.org>
Mon, 21 May 2012 09:56:03 +0000 (05:56 -0400)
gnutls_dh_params_export_pkcs3() returns 2 different sizes.
NUL observed by Janne Snabb

src/src/tls-gnu.c

index 3ea02bd529f3a59963740de0bd3821f300bb81e9..0ac72ad25b17e468e9833e061b2056ebbb31b5c8 100644 (file)
@@ -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);