Patch for wrong size allocation in ne_gnutls.c

Joe Orton joe at manyfish.co.uk
Wed Nov 14 15:47:14 EST 2018


On Wed, Nov 14, 2018 at 05:01:22PM +0100, Henrik Holst wrote:
>   ne_gnutls.c makes a malloc for the size of the pointer to the
> gnutls_pcert_st structure instead of the size of the structure itself.
> 
> I also changed from malloc to calloc in case gnutls_pcert_import_x509()
> reads from any of the structure members before filling it in (a bit unsure
> about the requirements of the GnuTLS library).
> 
> I've attached the patch both inline and as an attached file since Gmail
> (which I use) have a tendendency to bork inline patches:

Hi Henrik, great catch, thanks a lot!  I've pushed this to SVN (which is 
now working again).  There are a bunch of OpenSSL 1.1 fixes also pending 
for 0.30.x so I've been meaning to push out a new release.

Regards, Joe

> 
> --- ne_gnutls.c.org    2018-11-14 16:18:17.937532267 +0100
> +++ ne_gnutls.c    2018-11-14 16:18:33.465205564 +0100
> @@ -660,7 +660,7 @@
>                  return ret;
>              }
> 
> -            *pcert = gnutls_malloc(sizeof *pcert);
> +            *pcert = gnutls_calloc(1, sizeof **pcert);
>              gnutls_pcert_import_x509(*pcert,
> sess->client_cert->cert.subject, 0);
>              *pcert_length = 1;
>  #else /* !HAVE_GNUTLS_CERTIFICATE_SET_RETRIEVE_FUNCTION2 */

> --- ne_gnutls.c.org	2018-11-14 16:18:17.937532267 +0100
> +++ ne_gnutls.c	2018-11-14 16:18:33.465205564 +0100
> @@ -660,7 +660,7 @@
>                  return ret;
>              }
>              
> -            *pcert = gnutls_malloc(sizeof *pcert);
> +            *pcert = gnutls_calloc(1, sizeof **pcert);
>              gnutls_pcert_import_x509(*pcert, sess->client_cert->cert.subject, 0);
>              *pcert_length = 1;
>  #else /* !HAVE_GNUTLS_CERTIFICATE_SET_RETRIEVE_FUNCTION2 */




More information about the neon mailing list