Skip to content

Fixes #37#39

Merged
rlerdorf merged 7 commits intomasterfrom
fix-curl-mime-deprecation
Apr 4, 2026
Merged

Fixes #37#39
rlerdorf merged 7 commits intomasterfrom
fix-curl-mime-deprecation

Conversation

@rlerdorf
Copy link
Copy Markdown
Member

@rlerdorf rlerdorf commented Apr 4, 2026

  • Replace deprecated curl_formadd() / CURLFORM_* / CURLOPT_HTTPPOST with the MIME API (curl_mime_init(), curl_mime_addpart(), curl_mime_name(), curl_mime_data(), curl_mime_filedata(), curl_mime_type(), curl_mime_filename(), CURLOPT_MIMEPOST) for multipart form uploads
  • Guarded with #if LIBCURL_VERSION_NUM >= 0x073800 (7.56.0) with fallback to the old API for older libcurl
  • Properly frees the mime handle after the request completes

Fixes #37

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

This PR updates the cURL-based request engine to avoid libcurl 7.56+ deprecation warnings by switching multipart uploads from the legacy curl_formadd / CURLOPT_HTTPPOST API to the newer MIME API, while retaining a compile-time fallback for older libcurl versions.

Changes:

  • Use curl_mime_* + CURLOPT_MIMEPOST for multipart form uploads when LIBCURL_VERSION_NUM >= 0x073800 (7.56.0).
  • Keep the legacy curl_formadd / CURLOPT_HTTPPOST implementation for older libcurl.
  • Free the MIME handle after the request completes.

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

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

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

Comments suppressed due to low confidence (1)

oauth.c:1135

  • postval is allocated with estrdup() and then the pointer is advanced with ++postval, but the duplicated buffer is never freed. This leaks memory per multipart field (and also loses the base pointer needed for efree). Keep a separate variable for the allocated buffer and efree() it after the MIME part has been configured (libcurl copies the strings).
			/* swiped from ext/curl/interface.c to help with consistency */
			postval = estrdup(soo->multipart_files[i]);

			if (postval[0] == '@' && soo->multipart_params[i][0] == '@') {
				/* :< (chomp) @ */
				++soo->multipart_params[i];
				++postval;


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

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

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

Comments suppressed due to low confidence (1)

oauth.c:1136

  • In the MIME file upload branch, the code increments soo->multipart_params[i] (to skip the leading '@') which mutates the stored pointer in the soo object. Even though it is later freed/reset in oauth_fetch, mutating request state in-place is fragile and makes this function harder to reason about. Prefer using a local pointer (e.g., const char *name = soo->multipart_params[i] + 1) and leaving the stored array untouched.
			if (postval[0] == '@' && soo->multipart_params[i][0] == '@') {
				/* :< (chomp) @ */
				++soo->multipart_params[i];
				++postval;


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

@rlerdorf rlerdorf requested a review from Copilot April 4, 2026 22:27
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

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


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

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

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


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

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

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


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

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

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


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

@rlerdorf rlerdorf merged commit 7a10aa1 into master Apr 4, 2026
9 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.

Deprecations from cURL 7.56

2 participants