X509_GET_PUBKEY(3) return value check in libcrypto
authorinoguchi <inoguchi@openbsd.org>
Sat, 22 Jan 2022 00:31:23 +0000 (00:31 +0000)
committerinoguchi <inoguchi@openbsd.org>
Sat, 22 Jan 2022 00:31:23 +0000 (00:31 +0000)
ok beck@ tb@

lib/libcrypto/ocsp/ocsp_lib.c

index 8081a1c..09bccc0 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ocsp_lib.c,v 1.24 2022/01/07 09:45:52 tb Exp $ */
+/* $OpenBSD: ocsp_lib.c,v 1.25 2022/01/22 00:31:23 inoguchi Exp $ */
 /* Written by Tom Titchener <Tom_Titchener@groove.net> for the OpenSSL
  * project. */
 
@@ -96,7 +96,9 @@ OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, const X509 *issuer)
                iname = X509_get_subject_name(issuer);
                serial = NULL;
        }
-       ikey = X509_get0_pubkey_bitstr(issuer);
+       if ((ikey = X509_get0_pubkey_bitstr(issuer)) == NULL)
+               return NULL;
+
        return OCSP_cert_id_new(dgst, iname, ikey, serial);
 }