mirror of https://github.com/moparisthebest/curl
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
This commit is contained in:
parent
03a3dd9ee3
commit
7ac3e9f1ba
13
lib/url.c
13
lib/url.c
|
@ -1137,22 +1137,21 @@ 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);
|
||||
|
@ -1160,8 +1159,8 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||
argptr = strdup(argptr);
|
||||
if(!argptr) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
||||
if(checkprefix("Set-Cookie:", argptr))
|
||||
/* HTTP Header format line */
|
||||
|
@ -1172,6 +1171,10 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
|
|||
Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
|
||||
|
||||
free(argptr);
|
||||
}
|
||||
}
|
||||
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
|
||||
|
||||
break;
|
||||
#endif /* CURL_DISABLE_COOKIES */
|
||||
|
||||
|
|
Loading…
Reference in New Issue