Fix missing wc_AesFree on wc_AesGcmSetKey failure in Unwrap functions#306
Merged
bigbrett merged 2 commits intowolfSSL:mainfrom Mar 18, 2026
Merged
Fix missing wc_AesFree on wc_AesGcmSetKey failure in Unwrap functions#306bigbrett merged 2 commits intowolfSSL:mainfrom
bigbrett merged 2 commits intowolfSSL:mainfrom
Conversation
_AesGcmKeyUnwrap and _AesGcmDataUnwrap leaked an initialized AES context when wc_AesGcmSetKey failed after a successful wc_AesInit. Add wc_AesFree calls to match the cleanup pattern in the Wrap siblings. Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
send_size was only computed inside the initial-write block, so on a retry after a partial send it stayed 0, making remaining_size negative. That value wrapped to a huge size_t in send(), causing an immediate fatal error and making partial TCP writes unrecoverable. Move the send_size calculation before the conditional so it is always set from the caller-supplied size, regardless of whether this is the first attempt or a retry. Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
bigbrett
approved these changes
Mar 18, 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.
_AesGcmKeyUnwrap and _AesGcmDataUnwrap leaked an initialized AES context when wc_AesGcmSetKey failed after a successful wc_AesInit. Add wc_AesFree calls to match the cleanup pattern in the Wrap siblings.