Skip to content

Fix missing wc_AesFree on wc_AesGcmSetKey failure in Unwrap functions#306

Merged
bigbrett merged 2 commits intowolfSSL:mainfrom
sameehj:free
Mar 18, 2026
Merged

Fix missing wc_AesFree on wc_AesGcmSetKey failure in Unwrap functions#306
bigbrett merged 2 commits intowolfSSL:mainfrom
sameehj:free

Conversation

@sameehj
Copy link
Copy Markdown
Contributor

@sameehj sameehj commented Mar 18, 2026

_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.

_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>
@dgarske dgarske requested a review from bigbrett March 18, 2026 16:56
@bigbrett bigbrett merged commit 5e91715 into wolfSSL:main Mar 18, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants