From d31bc179b3a48351025c55756ce8be82bf9bfa4c Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Mon, 25 Apr 2016 08:56:54 -0400 Subject: [PATCH] Fix NULL deref in apps/pkcs7 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Thanks to Brian Carpenter for finding and reporting this. Reviewed-by: Emilia Käsper (cherry picked from commit 79356a83b78a2d936dcd022847465d9ebf6c67b1) --- apps/pkcs7.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/pkcs7.c b/apps/pkcs7.c index 643507f216..b677633183 100644 --- a/apps/pkcs7.c +++ b/apps/pkcs7.c @@ -235,12 +235,16 @@ int MAIN(int argc, char **argv) i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: - certs = p7->d.sign->cert; - crls = p7->d.sign->crl; + if (p7->d.sign != NULL) { + certs = p7->d.sign->cert; + crls = p7->d.sign->crl; + } break; case NID_pkcs7_signedAndEnveloped: - certs = p7->d.signed_and_enveloped->cert; - crls = p7->d.signed_and_enveloped->crl; + if (p7->d.signed_and_enveloped != NULL) { + certs = p7->d.signed_and_enveloped->cert; + crls = p7->d.signed_and_enveloped->crl; + } break; default: break; -- 2.25.1