aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-06-17 23:29:05 +0200
committerDaniel Stenberg <daniel@haxx.se>2013-06-17 23:29:05 +0200
commit7ac3e9f1ba7c96d32a46c72edb5819c4a342a31f (patch)
tree21a9c69e9e2b886641d4f73a52cb62b46a3d5af8
parent03a3dd9ee39e2ca4eea101360ae976e13586c01a (diff)
CURLOPT_COOKIELIST: take cookie share lock
When performing COOKIELIST operations the cookie lock needs to be taken for the cases where the cookies are shared among multiple handles! Verified by Benjamin Gilbert's updated test 506 Bug: http://curl.haxx.se/bug/view.cgi?id=1215 Reported-by: Benjamin Gilbert
-rw-r--r--lib/url.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/lib/url.c b/lib/url.c
index e116a5b68..7ba496986 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1137,41 +1137,44 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
if(argptr == NULL)
break;
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
+
if(Curl_raw_equal(argptr, "ALL")) {
/* clear all cookies */
Curl_cookie_clearall(data->cookies);
- break;
}
else if(Curl_raw_equal(argptr, "SESS")) {
/* clear session cookies */
Curl_cookie_clearsess(data->cookies);
- break;
}
else if(Curl_raw_equal(argptr, "FLUSH")) {
/* flush cookies to file */
Curl_flush_cookies(data, 0);
- break;
}
+ else {
+ if(!data->cookies)
+ /* if cookie engine was not running, activate it */
+ data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
- if(!data->cookies)
- /* if cookie engine was not running, activate it */
- data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
+ argptr = strdup(argptr);
+ if(!argptr) {
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ else {
- argptr = strdup(argptr);
- if(!argptr) {
- result = CURLE_OUT_OF_MEMORY;
- break;
- }
+ if(checkprefix("Set-Cookie:", argptr))
+ /* HTTP Header format line */
+ Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL);
- if(checkprefix("Set-Cookie:", argptr))
- /* HTTP Header format line */
- Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL);
+ else
+ /* Netscape format line */
+ Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
- else
- /* Netscape format line */
- Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
+ free(argptr);
+ }
+ }
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
- free(argptr);
break;
#endif /* CURL_DISABLE_COOKIES */