mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #3344 from guidovranken/PKCS7_EncodeSigned-leak-fix
Check the right size before freeing flatSignedAttribs in PKCS7_EncodeSignedpull/3712/head
commit
7eb71b1bb1
|
@ -2448,7 +2448,7 @@ static int PKCS7_EncodeSigned(PKCS7* pkcs7, ESD* esd,
|
|||
ret = wc_PKCS7_SignedDataBuildSignature(pkcs7, flatSignedAttribs,
|
||||
flatSignedAttribsSz, esd);
|
||||
if (ret < 0) {
|
||||
if (flatSignedAttribs)
|
||||
if (esd->signedAttribsSz != 0)
|
||||
XFREE(flatSignedAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(esd, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
@ -2513,7 +2513,7 @@ static int PKCS7_EncodeSigned(PKCS7* pkcs7, ESD* esd,
|
|||
/* if using header/footer, we are not returning the content */
|
||||
if (output2 && output2Sz) {
|
||||
if (total2Sz > *output2Sz) {
|
||||
if (flatSignedAttribs)
|
||||
if (esd->signedAttribsSz != 0)
|
||||
XFREE(flatSignedAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(esd, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
@ -2536,7 +2536,7 @@ static int PKCS7_EncodeSigned(PKCS7* pkcs7, ESD* esd,
|
|||
}
|
||||
|
||||
if (totalSz > *outputSz) {
|
||||
if (flatSignedAttribs)
|
||||
if (esd->signedAttribsSz != 0)
|
||||
XFREE(flatSignedAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(esd, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
@ -2549,7 +2549,7 @@ static int PKCS7_EncodeSigned(PKCS7* pkcs7, ESD* esd,
|
|||
}
|
||||
|
||||
if (output == NULL) {
|
||||
if (flatSignedAttribs)
|
||||
if (esd->signedAttribsSz != 0)
|
||||
XFREE(flatSignedAttribs, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
XFREE(esd, pkcs7->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
|
Loading…
Reference in New Issue