Skip to content

add missing wc_AesFree on AesGcmSetKey failure in key/data unwrap#307

Merged
bigbrett merged 1 commit intomainfrom
aes_free
Mar 18, 2026
Merged

add missing wc_AesFree on AesGcmSetKey failure in key/data unwrap#307
bigbrett merged 1 commit intomainfrom
aes_free

Conversation

@jackctj117
Copy link
Copy Markdown
Contributor

This pull request introduces a small but important fix to the AES-GCM key handling logic. Specifically, it ensures that resources are properly freed if key setup fails, preventing potential memory leaks.

  • Memory management improvements:
    • Added calls to wc_AesFree(aes) in both _AesGcmKeyUnwrap and _AesGcmDataUnwrap to free AES context memory if wc_AesGcmSetKey fails. (src/wh_server_keystore.c) [1] [2]

Copilot AI review requested due to automatic review settings March 18, 2026 15:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an AES-GCM resource cleanup gap in the server keystore unwrap paths so the AES context is freed when wc_AesGcmSetKey fails, preventing leaks (especially relevant for HW-backed AES contexts).

Changes:

  • Add wc_AesFree(aes) on wc_AesGcmSetKey failure in _AesGcmKeyUnwrap.
  • Add wc_AesFree(aes) on wc_AesGcmSetKey failure in _AesGcmDataUnwrap.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@bigbrett bigbrett merged commit 142b1e2 into main Mar 18, 2026
55 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.

4 participants