From 92d01611ff5a17bc131c7c36792d638eb1bc17bc Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Thu, 13 Jan 2022 13:26:32 +0000 Subject: [PATCH] Fix buffer overflow in GetOID When converting BER to DER we switched the pointer for pkiMsg to the DER but not the size which could cause buffer overflow. Fixes ZD13471 --- wolfcrypt/src/pkcs7.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index 3bcbfec6f..498d50db7 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -10497,8 +10497,10 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* in, #ifdef ASN_BER_TO_DER /* check if content was BER and has been converted to DER */ - if (pkcs7->derSz > 0) + if (pkcs7->derSz > 0) { pkiMsg = in = pkcs7->der; + pkiMsgSz = inSz = pkcs7->derSz; + } #endif decryptedKey = (byte*)XMALLOC(MAX_ENCRYPTED_KEY_SZ, pkcs7->heap,