cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_duphandle issue

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 9 Mar 2009 00:24:21 +0100 (CET)

On Fri, 6 Mar 2009, Frank Hempel wrote:

> I noticed that curl_easy_duphandle does not necessarily duplicates the
> CURLOPT_COOKIEFILE option. It only enables the cookie engine in the
> destination handle if data->cookies is not NULL (where data is the source
> handle). In case of a new initialized handle which just had the cookie
> support enabled by a curl_easy_setopt(handle, CURL_COOKIEFILE, "")-call,
> handle->cookies is still NULL because the setopt-call only appends the value
> to data->change.cookielist, hence duplicating this handle will not have the
> cookie engine switched on. Attached is a patch against version 7.19.4 which
> will additionally duplicate data->change.cookielist if not NULL.

Oh, nice catch and indeed not a shabby approach to fix it. Thanks for the
patch.

One nit, one suggestion on the patch.

Nit: if one curl_slist_append() call fails due to out of mem, this will lead
      to leaked memory. A failure must cleanup the (incomplete) duplicated
      list before returning.

Suggestion: how about making a separate "Curl_dup_cookielist" function and put
      it in the lib/cookie.c file where the other cookie functions live? To me
      it would feel better to keep them close to each other rather than to put
      the full logic within the curl_easy_duphandle() function.

-- 
  / daniel.haxx.se
Received on 2009-03-09