Code

http: clear POSTFIELDS when initializing a slot
authorJunio C Hamano <gitster@pobox.com>
Tue, 26 Apr 2011 15:04:49 +0000 (08:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 Apr 2011 17:44:33 +0000 (10:44 -0700)
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>
Acked-by: Shawn Pearce <spearce@spearce.org>
http.c

diff --git a/http.c b/http.c
index ed6414a2aaa4e0f6cf7672a089f49060aad62bfb..b642eac978025a1078f3b7f6233083f0d5dbddfa 100644 (file)
--- 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);