Skip to content

connect: remove deref of freed pointer in trace call#21649

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/peer-gone
Closed

connect: remove deref of freed pointer in trace call#21649
bagder wants to merge 1 commit into
masterfrom
bagder/peer-gone

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented May 16, 2026

Spotted by CodeSonar

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

Fixes a use-after-free in a trace call within cf_setup_connect(): when Curl_cf_socks_proxy_insert_after() fails, dest may have been freed, so the original code dereferencing dest->hostname/dest->port in CURL_TRC_CF before the error check was unsafe. The error path now logs without touching dest and returns immediately.

Changes:

  • On failure of adding the SOCKS filter, log without dereferencing dest and return early.
  • The success path retains the detailed trace using dest->hostname and dest->port.

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

@bagder bagder marked this pull request as ready for review May 17, 2026 12:20
@bagder bagder closed this in e8c1023 May 17, 2026
@bagder bagder deleted the bagder/peer-gone branch May 17, 2026 12:20
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants