Skip to content

Commit

Permalink
Fix a possible memleak in CMS_sign_receipt
Browse files Browse the repository at this point in the history
When an error happens after cms_encode_Receipt
the ASN1_OCTET_STRING object "os" may be leaked.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #22758)

(cherry picked from commit 3e3aadd)
  • Loading branch information
bernd-edlinger authored and levitte committed Nov 22, 2023
1 parent 438c137 commit 700371f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/cms/cms_smime.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
{
CMS_SignerInfo *rct_si;
CMS_ContentInfo *cms = NULL;
ASN1_OCTET_STRING **pos, *os;
ASN1_OCTET_STRING **pos, *os = NULL;
BIO *rct_cont = NULL;
int r = 0;
const CMS_CTX *ctx = si->cms_ctx;
Expand Down Expand Up @@ -620,6 +620,7 @@ CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
if (r)
return cms;
CMS_ContentInfo_free(cms);
ASN1_OCTET_STRING_free(os);
return NULL;

}
Expand Down

0 comments on commit 700371f

Please sign in to comment.