OpensslPkg: Fix Pkcs7GetCertificatesList#201
Merged
Flickdm merged 1 commit intomicrosoft:mainfrom Mar 24, 2026
Merged
Conversation
…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.
5 tasks
apop5
approved these changes
Mar 23, 2026
Javagedes
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
How This Was Tested
Host Based Tests microsoft/mu_basecore#1714
Integration Instructions
N/A