Skip to content

sspi: free libcurl allocated memory with curlx_free#21990

Closed
bagder wants to merge 5 commits into
masterfrom
bagder/sspi-memory
Closed

sspi: free libcurl allocated memory with curlx_free#21990
bagder wants to merge 5 commits into
masterfrom
bagder/sspi-memory

Conversation

@bagder

@bagder bagder commented Jun 12, 2026

Copy link
Copy Markdown
Member

DecryptMessage() decrypts the buffer in place, overwriting the original contents. It does not allocate any new buffer so the single original buffer should be freed using the same memory "system" that allocated it.

Reported-by: Trail of Bits

DecryptMessage() decrypts the buffer in place, overwriting the original
contents. It does not allocate any new buffer so the single original
buffer should be freed using the same memory "system" that allocated it.

Reported-by: Trail of Bits
@bagder bagder requested a review from jay June 12, 2026 12:40
@bagder bagder added Windows Windows-specific cryptography labels Jun 12, 2026
@bagder bagder marked this pull request as ready for review June 12, 2026 13:35
@bagder bagder requested a review from Copilot June 12, 2026 13:35

Copilot AI left a comment

Copy link
Copy Markdown

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 adjusts SSPI/Kerberos handling to avoid freeing buffers with FreeContextBuffer() when the decrypted data is written in-place into an existing libcurl-allocated buffer (per DecryptMessage() behavior).

Changes:

  • Clarify via comments that DecryptMessage() decrypts in place and does not allocate a new buffer.
  • Remove FreeContextBuffer() calls for decrypted buffers that are not SSPI-allocated.
  • Switch to freeing the original libcurl-allocated buffer (curlx_free) in the SOCKS SSPI path.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/vauth/krb5_sspi.c Removes an incorrect FreeContextBuffer() and documents in-place decryption behavior.
lib/socks_sspi.c Removes FreeContextBuffer() usage for decrypted data and updates cleanup to free the libcurl-allocated buffer.

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

Comment thread lib/socks_sspi.c
@jay

jay commented Jun 12, 2026

Copy link
Copy Markdown
Member

Comment thread lib/socks_sspi.c Outdated
@bagder bagder closed this in 8d3c4fe Jun 13, 2026
@bagder bagder deleted the bagder/sspi-memory branch June 13, 2026 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cryptography Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

3 participants