Skip to content

Make Curl CA path ownership safe#1464

Merged
bmehta001 merged 9 commits into
microsoft:mainfrom
bmehta001:bhamehta/curl-ca-path-ownership
Jun 9, 2026
Merged

Make Curl CA path ownership safe#1464
bmehta001 merged 9 commits into
microsoft:mainfrom
bmehta001:bhamehta/curl-ca-path-ownership

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

This is split out of #1416 to keep the review surface small and focused.

Changes:

  • Store Curl CA path strings with stable ownership.
  • Avoid keeping pointers to transient or externally-owned string data in Curl option storage.

Validation performed locally:

  • git diff --check

Split the Curl CA path fix into a smaller review slice. Store CA path strings with stable ownership so Curl options do not keep pointers to transient or externally-owned string data.

Files changed: lib/http/HttpClient_Curl.hpp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 requested a review from a team as a code owner June 5, 2026 03:14
@bmehta001 bmehta001 requested a review from Copilot June 5, 2026 03:19
@bmehta001 bmehta001 self-assigned this Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves the safety of libcurl option configuration by ensuring the CA bundle path passed to CURLOPT_CAINFO has stable ownership for the lifetime of a CurlHttpOperation.

Changes:

  • Persist the sslCaInfo string inside CurlHttpOperation (m_sslCaInfo) instead of relying on a potentially transient caller-owned string.
  • Update CURLOPT_CAINFO setup to use the owned m_sslCaInfo buffer.

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

Comment thread lib/http/HttpClient_Curl.hpp
@bmehta001 bmehta001 force-pushed the bhamehta/curl-ca-path-ownership branch from ec189ee to 1367e82 Compare June 5, 2026 15:33
Explain why CurlHttpOperation owns the CA path string but intentionally does not copy the request body. The SDK upload path keeps the request alive until Send completes, and copying the body would duplicate every upload payload.

Files changed: lib/http/HttpClient_Curl.hpp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bmehta001 and others added 3 commits June 5, 2026 10:50
Explain that request headers are copied into the owned curl_slist during construction, so CurlHttpOperation does not need to keep the original header map alive for the operation lifetime.

Files changed: lib/http/HttpClient_Curl.hpp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread lib/http/HttpClient_Curl.hpp Outdated
Comment thread lib/http/HttpClient_Curl.hpp Outdated
bmehta001 and others added 2 commits June 5, 2026 15:26
Co-authored-by: Baiju Meswani <baijumeswani@gmail.com>
Apply the reviewed header-loop cleanup and modernize a few local internals in HttpClient_Curl.hpp without changing behavior. This preserves the existing request-body lifetime model while reducing unnecessary casts/null usage and avoiding loss of the old response buffer if realloc fails.

Files changed: lib/http/HttpClient_Curl.hpp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread lib/http/HttpClient_Curl.hpp

@baijumeswani baijumeswani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good. copilot had some suggestions. not sure if they need to be addressed.

Remove the defaulted temporary arguments for requestHeaders and requestBody so a caller can no longer bind a temporary to the requestBody reference member, which Send() reads after construction. Production already passes owned values (HttpClient_Curl.cpp); update the unit tests to pass fixture-lifetime headers/body instead of temporaries.

Addresses the Copilot review note about a potentially dangling requestBody reference.

Files changed:

- lib/http/HttpClient_Curl.hpp

- tests/unittests/HttpClientCurlTests.cpp

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread lib/http/HttpClient_Curl.hpp Outdated
The constructor comment claimed both requestHeaders and requestBody must
outlive the operation, but requestHeaders is only copied into the curl_slist
during construction; only requestBody is stored by reference and read by
Send(). Update the comment so it no longer misleads callers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@bmehta001 bmehta001 merged commit 823c3b2 into microsoft:main Jun 9, 2026
35 of 39 checks passed
@bmehta001 bmehta001 deleted the bhamehta/curl-ca-path-ownership branch June 9, 2026 05:45
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