Skip to content

mbedtls: cleanup more without care for 'initialized'#21440

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/mbedtls-cleanup
Closed

mbedtls: cleanup more without care for 'initialized'#21440
bagder wants to merge 1 commit into
masterfrom
bagder/mbedtls-cleanup

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Apr 24, 2026

Several mbedTLS resources (entropy/CTR-DRBG, CA/client certs, keys, CRL) are initialized and may allocate memory before initialized is set, and must still be cleaned up.

Follow-up to 1c4813c

Caught by Codex Security

Several mbedTLS resources (entropy/CTR-DRBG, CA/client certs, keys, CRL)
are initialized and may allocate memory before initialized is set, and
must still be cleaned up.

Follow-up to 1c4813c

Caught by Codex Security
@bagder bagder added the TLS label Apr 24, 2026
@bagder bagder requested a review from Copilot April 24, 2026 14:54
@bagder bagder marked this pull request as ready for review April 24, 2026 14:54
Copy link
Copy Markdown

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

Ensures mbedTLS-related resources are cleaned up even when backend->initialized was never set, preventing leaks on early failures during TLS setup.

Changes:

  • Always free client/CA certs, private key, CRL (when enabled), configured ciphersuites, and mbedtls_ssl_config in mbedtls_close()
  • Keep mbedtls_ssl_free(&backend->ssl) guarded by backend->initialized

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

@bagder bagder closed this in d19a039 Apr 24, 2026
@bagder bagder deleted the bagder/mbedtls-cleanup branch May 8, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants