Skip to content

OpensslPkg: Fix Pkcs7GetCertificatesList#201

Merged
Flickdm merged 1 commit intomicrosoft:mainfrom
Flickdm:fix/pkcs7-getcertificateslist-newp7data-clobber
Mar 24, 2026
Merged

OpensslPkg: Fix Pkcs7GetCertificatesList#201
Flickdm merged 1 commit intomicrosoft:mainfrom
Flickdm:fix/pkcs7-getcertificateslist-newp7data-clobber

Conversation

@Flickdm
Copy link
Copy Markdown
Member

@Flickdm Flickdm commented Mar 23, 2026

Description

Fix Pkcs7GetCertificatesList clobbering NewP7Data

d2i_PKCS7 advances the pointer passed to it past the consumed bytes. Pkcs7GetCertificatesList was passing &NewP7Data directly, so after the call NewP7Data no longer pointed at the start of the malloc-allocated wrap buffer. The subsequent free(NewP7Data) therefore tried to free from the middle of the buffer, causing a heap error at runtime.

Fix by introducing a local Temp pointer for d2i_PKCS7 (matching the pattern already used correctly in Pkcs7GetSigners), so NewP7Data retains the original malloc base address and can be safely freed.

For details on how to complete these options and their meaning refer to CONTRIBUTING.md.

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

Host Based Tests microsoft/mu_basecore#1714

Integration Instructions

N/A

…7Data

d2i_PKCS7 advances the pointer passed to it past the consumed bytes.
Pkcs7GetCertificatesList was passing &NewP7Data directly, so after the
call NewP7Data no longer pointed at the start of the malloc-allocated
wrap buffer.  The subsequent free(NewP7Data) therefore tried to free
from the middle of the buffer, causing a heap error at runtime.

Fix by introducing a local Temp pointer for d2i_PKCS7 (matching the
pattern already used correctly in Pkcs7GetSigners), so NewP7Data
retains the original malloc base address and can be safely freed.
@mu-automation mu-automation Bot added the impact:non-functional Does not have a functional impact label Mar 23, 2026
@Flickdm Flickdm marked this pull request as ready for review March 23, 2026 18:16
@Flickdm Flickdm requested review from Javagedes and apop5 March 23, 2026 18:20
@Flickdm Flickdm merged commit 0ac12f9 into microsoft:main Mar 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:non-functional Does not have a functional impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants