From e497a8f5898158969989e91cefd1eb48703e93ac Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Sat, 6 Mar 2021 08:58:37 +0700 Subject: [PATCH] sanity check on size before compare --- wolfcrypt/src/pkcs7.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 2e93f4b58..90c740e8e 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -8423,6 +8423,9 @@ static int wc_PKCS7_DecryptKtri(PKCS7* pkcs7, byte* in, word32 inSz, if (GetLength(pkiMsg, idx, &length, pkiMsgSz) < 0) return ASN_PARSE_E; + if (KEYID_SIZE > pkiMsgSz - (*idx)) + return BUFFER_E; + /* if we found correct recipient, SKID will match */ if (XMEMCMP(pkiMsg + (*idx), pkcs7->issuerSubjKeyId, KEYID_SIZE) == 0) {