forked from wolfSSL/wolfssl
PKCS7: In EncodeEncryptedData, free the attribs and flattenedAttribs if
they were allocated, not based on if they should be allocated.
This commit is contained in:
@@ -11751,10 +11751,10 @@ int wc_PKCS7_EncodeEncryptedData(PKCS7* pkcs7, byte* output, word32 outputSz)
|
|||||||
|
|
||||||
if (totalSz > (int)outputSz) {
|
if (totalSz > (int)outputSz) {
|
||||||
WOLFSSL_MSG("PKCS#7 output buffer too small");
|
WOLFSSL_MSG("PKCS#7 output buffer too small");
|
||||||
if (pkcs7->unprotectedAttribsSz != 0) {
|
if (attribs != NULL)
|
||||||
XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
|
if (flatAttribs != NULL)
|
||||||
XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
}
|
|
||||||
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
return BUFFER_E;
|
return BUFFER_E;
|
||||||
@@ -11790,10 +11790,12 @@ int wc_PKCS7_EncodeEncryptedData(PKCS7* pkcs7, byte* output, word32 outputSz)
|
|||||||
idx += attribsSetSz;
|
idx += attribsSetSz;
|
||||||
XMEMCPY(output + idx, flatAttribs, attribsSz);
|
XMEMCPY(output + idx, flatAttribs, attribsSz);
|
||||||
idx += attribsSz;
|
idx += attribsSz;
|
||||||
XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
|
||||||
XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attribs != NULL)
|
||||||
|
XFREE(attribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
|
if (flatAttribs != NULL)
|
||||||
|
XFREE(flatAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
XFREE(plain, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user