Don't pass uninitialized pointer to ASN1_STRING_to_UTF8()
authortb <tb@openbsd.org>
Fri, 20 May 2022 08:00:05 +0000 (08:00 +0000)
committertb <tb@openbsd.org>
Fri, 20 May 2022 08:00:05 +0000 (08:00 +0000)
Exposed by recent rewrite of ASN1_STRING_to_UTF8(). Found via grep
after fixing CID 352831.

ok jsing

lib/libcrypto/pkcs12/p12_kiss.c

index 54a8092..1e221f4 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: p12_kiss.c,v 1.21 2021/07/09 14:08:00 tb Exp $ */
+/* $OpenBSD: p12_kiss.c,v 1.22 2022/05/20 08:00:05 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 1999.
  */
@@ -265,7 +265,7 @@ parse_bag(PKCS12_SAFEBAG *bag, const char *pass, int passlen, EVP_PKEY **pkey,
                }
                if (fname) {
                        int len, r;
-                       unsigned char *data;
+                       unsigned char *data = NULL;
                        len = ASN1_STRING_to_UTF8(&data, fname);
                        if (len >= 0) {
                                r = X509_alias_set1(x509, data, len);