From 2e64f1b5d5838ab80786bf851e88b2254879c6ae Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Fri, 6 Nov 2015 16:02:39 -0800 Subject: [PATCH] Check PKCS#8 pkey field is valid before cleansing. (Imported from upstream's 52e028b9de371da62c1e51b46592517b1068d770.) Change-Id: If980d774671b9b5ba997db3fd7d4043525a85609 Reviewed-on: https://boringssl-review.googlesource.com/6445 Reviewed-by: David Benjamin Reviewed-by: Adam Langley --- crypto/pkcs8/p8_pkey.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/pkcs8/p8_pkey.c b/crypto/pkcs8/p8_pkey.c index bd9d30ca..c69d0fac 100644 --- a/crypto/pkcs8/p8_pkey.c +++ b/crypto/pkcs8/p8_pkey.c @@ -66,7 +66,7 @@ static int pkey_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, /* Since the structure must still be valid use ASN1_OP_FREE_PRE */ if (operation == ASN1_OP_FREE_PRE) { PKCS8_PRIV_KEY_INFO *key = (PKCS8_PRIV_KEY_INFO *)*pval; - if (key->pkey && + if (key->pkey && key->pkey->type == V_ASN1_OCTET_STRING && key->pkey->value.octet_string) { OPENSSL_cleanse(key->pkey->value.octet_string->data, key->pkey->value.octet_string->length);