http: prevent segfault during curl handle reuse
If a curl handle is configured with special options, they may reference information that is freed after the request is complete which can cause a segfault if the curl handle is reused for a different type of request. This patch resets these options to a safe state when a transfer slot is assigned to a new request. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nick Hengeveld committed
May 31, 2006 at 16:25 UTC
9094950d738176db2c0d9d7e4e3843c056a5d222
1 file changed
+6
-3
http.c
+6
-3
@@ -25,7 +25,6 @@ long curl_low_speed_limit = -1;
25
long curl_low_speed_time = -1;
26
27
struct curl_slist *pragma_header;
28
-struct curl_slist *no_range_header;
28
29
struct active_request_slot *active_queue_head = NULL;
30
@@ -208,7 +207,6 @@ void http_init(void)
207
curl_global_init(CURL_GLOBAL_ALL);
208
209
pragma_header = curl_slist_append(pragma_header, "Pragma: no-cache");
211
- no_range_header = curl_slist_append(no_range_header, "Range:");
210
211
#ifdef USE_CURL_MULTI
212
{
@@ -344,9 +342,14 @@ struct active_request_slot *get_active_slot(void)
342
slot->finished = NULL;
343
slot->callback_data = NULL;
344
slot->callback_func = NULL;
345
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
346
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header);
348
- curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_range_header);
347
curl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, curl_errorstr);
348
+ curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, NULL);
349
+ curl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);
350
+ curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);
351
+ curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);
352
+ curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
353
354
return slot;
355
}