From bdec6f2b20440b53859e472d185a21f1951341d5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 9 Mar 2009 12:21:46 +0000 Subject: - Frank Hempel found out a bug and provided the fix: curl_easy_duphandle did not necessarily duplicate the CURLOPT_COOKIEFILE option. It only enabled the cookie engine in the destination handle if data->cookies is not NULL (where data is the source handle). In case of a newly initialized handle which just had the cookie support enabled by a curl_easy_setopt(handle, CURL_COOKIEFILE, "")-call, handle->cookies was still NULL because the setopt-call only appends the value to data->change.cookielist, hence duplicating this handle would not have the cookie engine switched on. We also concluded that the slist-functionality would be suitable for being put in its own module rather than simply hanging out in lib/sendf.c so I created lib/slist.[ch] for them. --- lib/easy.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/easy.c') diff --git a/lib/easy.c b/lib/easy.c index c0670d519..dc6c59366 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -84,6 +84,7 @@ #include "sendf.h" /* for failf function prototype */ #include "http_ntlm.h" #include "connect.h" /* for Curl_getconnectinfo */ +#include "slist.h" #define _MPRINTF_REPLACE /* use our functions only */ #include @@ -648,6 +649,16 @@ CURL *curl_easy_duphandle(CURL *incurl) /* duplicate all values in 'change' */ +#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) + if(data->change.cookielist) { + outcurl->change.cookielist = + Curl_slist_duplicate(data->change.cookielist); + + if (!outcurl->change.cookielist) + break; + } +#endif /* CURL_DISABLE_HTTP */ + if(data->change.url) { outcurl->change.url = strdup(data->change.url); if(!outcurl->change.url) @@ -692,6 +703,10 @@ CURL *curl_easy_duphandle(CURL *incurl) Curl_rm_connc(outcurl->state.connc); if(outcurl->state.headerbuff) free(outcurl->state.headerbuff); +#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) + if(outcurl->change.cookielist) + curl_slist_free_all(outcurl->change.cookielist); +#endif if(outcurl->change.url) free(outcurl->change.url); if(outcurl->change.referer) -- cgit v1.2.3