git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] http: clear POSTFIELDS when initializing a slot

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 26, 2011, 15:28 UTC
Message-ID
<7v39l5ghgj.fsf@alter.siamese.dyndns.org>

After posting a short request using CURLOPT_POSTFIELDS, if the slot is reused for posting a large payload, the slot ends up having both POSTFIELDS (which now points at a random garbage) and READFUNCTION, in which case the curl library tries to use the stale POSTFIELDS.

Clear it as part of the general slot initialization in get_active_slot().
Heavylifting-by: Shawn Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This came up while Shawn was looking at the smart HTTP code again.  It
   makes me wonder why we do not use curl_easy_reset() in this function,
   though...
 http.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/http.c b/http.c
index ed6414a..b642eac 100644
--- a/http.c
+++ b/http.c
@@ -494,6 +494,7 @@ struct active_request_slot *get_active_slot(void)
 	curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, NULL);
 	curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);
 	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
+	curl_easy_setopt(slot->curl, CURLOPT_POSTFIELDS, NULL);
 	curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
 	curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
 
-- 
1.7.5
Next: Shawn Pearce
Message 1 of 2 in “http: clear POSTFIELDS when initializing a slot”
  1. http: clear POSTFIELDS when initializing a slotJunio C Hamano, Apr 26, 2011
  2. Shawn PearceApr 26, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.