{"thread":{"id":"4363","subject":"[PATCH] http: prevent segfault during curl handle reuse","startedAt":"2006-05-31T23:25:03Z","lastAt":"2006-05-31T23:25:03Z","messageCount":1,"participants":["Nick Hengeveld"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"21040","messageId":"20060531232503.GC12261@reactrix.com","threadId":"4363","inReplyTo":null,"subject":"[PATCH] http: prevent segfault during curl handle reuse","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2006-05-31T23:25:03Z","receivedAt":"2006-05-31T23:25:03Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"If a curl handle is configured with special options, they may reference\ninformation that is freed after the request is complete which can cause\na segfault if the curl handle is reused for a different type of request.\n\nThis patch resets these options to a safe state when a transfer slot is\nassigned to a new request.\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n---\n http.c |    9 ++++++---\n 1 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 0cb42a8..146cf7b 100644\n--- a/http.c\n+++ b/http.c\n@@ -25,7 +25,6 @@ long curl_low_speed_limit = -1;\n long curl_low_speed_time = -1;\n \n struct curl_slist *pragma_header;\n-struct curl_slist *no_range_header;\n \n struct active_request_slot *active_queue_head = NULL;\n \n@@ -208,7 +207,6 @@ void http_init(void)\n \tcurl_global_init(CURL_GLOBAL_ALL);\n \n \tpragma_header = curl_slist_append(pragma_header, \"Pragma: no-cache\");\n-\tno_range_header = curl_slist_append(no_range_header, \"Range:\");\n \n #ifdef USE_CURL_MULTI\n \t{\n@@ -344,9 +342,14 @@ #endif\n \tslot->finished = NULL;\n \tslot->callback_data = NULL;\n \tslot->callback_func = NULL;\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);\n \tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, pragma_header);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, no_range_header);\n \tcurl_easy_setopt(slot->curl, CURLOPT_ERRORBUFFER, curl_errorstr);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, NULL);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_READFUNCTION, NULL);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, NULL);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 0);\n+\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);\n \n \treturn slot;\n }\n-- \n1.3.3.g2186-dirty\n"}]}