do_ext_i2d(): malloc -> calloc
authortb <tb@openbsd.org>
Tue, 18 Jun 2024 05:35:30 +0000 (05:35 +0000)
committertb <tb@openbsd.org>
Tue, 18 Jun 2024 05:35:30 +0000 (05:35 +0000)
requested by jsing on review

lib/libcrypto/x509/x509_conf.c

index ed63f1c..d7c1232 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: x509_conf.c,v 1.10 2024/06/18 05:34:09 tb Exp $ */
+/* $OpenBSD: x509_conf.c,v 1.11 2024/06/18 05:35:30 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 1999.
  */
@@ -204,7 +204,7 @@ do_ext_i2d(const X509V3_EXT_METHOD *method, int ext_nid, int crit,
 
                if ((ext_len = method->i2d(ext_struc, NULL)) <= 0)
                        goto merr;
-               if ((ext_der = malloc(ext_len)) == NULL)
+               if ((ext_der = calloc(1, ext_len)) == NULL)
                        goto merr;
                p = ext_der;
                if (method->i2d(ext_struc, &p) != ext_len)