make X509_CRL_METHOD_free() NULL-safe

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

make X509_CRL_METHOD_free() NULL-safe

Theo Buehler-5
This is a practically unused function (both in our tree and globally),
but it is the only remaining public *_free() function in libcrypto that
segfaults on being passed NULL. I'll of course add it to the regress
tests should this go in.

Index: lib/libcrypto/asn1/x_crl.c
===================================================================
RCS file: /var/cvs/src/lib/libcrypto/asn1/x_crl.c,v
retrieving revision 1.30
diff -u -p -r1.30 x_crl.c
--- lib/libcrypto/asn1/x_crl.c 17 Mar 2018 14:33:20 -0000 1.30
+++ lib/libcrypto/asn1/x_crl.c 22 Apr 2018 12:12:14 -0000
@@ -675,7 +675,7 @@ X509_CRL_METHOD_new(int (*crl_init)(X509
 void
 X509_CRL_METHOD_free(X509_CRL_METHOD *m)
 {
- if (!(m->flags & X509_CRL_METHOD_DYNAMIC))
+ if (m == NULL || !(m->flags & X509_CRL_METHOD_DYNAMIC))
  return;
  free(m);
 }

Reply | Threaded
Open this post in threaded view
|

Re: make X509_CRL_METHOD_free() NULL-safe

Brent Cook
OK bcook@

On Mon, Apr 23, 2018 at 3:27 AM, Theo Buehler <[hidden email]> wrote:

> This is a practically unused function (both in our tree and globally),
> but it is the only remaining public *_free() function in libcrypto that
> segfaults on being passed NULL. I'll of course add it to the regress
> tests should this go in.
>
> Index: lib/libcrypto/asn1/x_crl.c
> ===================================================================
> RCS file: /var/cvs/src/lib/libcrypto/asn1/x_crl.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 x_crl.c
> --- lib/libcrypto/asn1/x_crl.c  17 Mar 2018 14:33:20 -0000      1.30
> +++ lib/libcrypto/asn1/x_crl.c  22 Apr 2018 12:12:14 -0000
> @@ -675,7 +675,7 @@ X509_CRL_METHOD_new(int (*crl_init)(X509
>  void
>  X509_CRL_METHOD_free(X509_CRL_METHOD *m)
>  {
> -       if (!(m->flags & X509_CRL_METHOD_DYNAMIC))
> +       if (m == NULL || !(m->flags & X509_CRL_METHOD_DYNAMIC))
>                 return;
>         free(m);
>  }
>
Reply | Threaded
Open this post in threaded view
|

Re: make X509_CRL_METHOD_free() NULL-safe

kinichiro inoguchi
OK inoguchi@