aboutsummaryrefslogtreecommitdiff
path: root/lib/cookie.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-08-17 08:55:43 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-08-17 08:55:43 +0000
commita676c18502d5ec3128db11accf04d6de3f9be949 (patch)
tree71335eb19d493e7322337c3e66d19f7f5e146ee2 /lib/cookie.c
parent362912ff838d09a57e21827a3c148a52fca3af03 (diff)
- Jeff Pohlmeyer found out that if you ask libcurl to load a cookiefile (with
CURLOPT_COOKIEFILE), add a cookie (with CURLOPT_COOKIELIST), tell it to write the result to a given cookie jar and then never actually call curl_easy_perform() - the given file(s) to read was never read but the output file was written and thus it caused a "funny" result. - While doing some tests for the bug above, I noticed that Firefox generates large numbers (for the expire time) in the cookies.txt file and libcurl didn't treat them properly. Now it does.
Diffstat (limited to 'lib/cookie.c')
-rw-r--r--lib/cookie.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index 0328f20d8..0f6d681db 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -94,6 +94,8 @@ Example set of cookies:
#include "strtok.h"
#include "sendf.h"
#include "memory.h"
+#include "share.h"
+#include "strtoofft.h"
/* The last #include file should be: */
#ifdef CURLDEBUG
@@ -133,6 +135,27 @@ static bool tailmatch(const char *little, const char *bigone)
return (bool)strequal(little, bigone+biglen-littlelen);
}
+/*
+ * Load cookies from all given cookie files (CURLOPT_COOKIEFILE).
+ */
+void Curl_cookie_loadfiles(struct SessionHandle *data)
+{
+ struct curl_slist *list = data->change.cookielist;
+ if(list) {
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
+ while(list) {
+ data->cookies = Curl_cookie_init(data,
+ list->data,
+ data->cookies,
+ data->set.cookiesession);
+ list = list->next;
+ }
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
+ curl_slist_free_all(data->change.cookielist); /* clean up list */
+ data->change.cookielist = NULL; /* don't do this again! */
+ }
+}
+
/****************************************************************************
*
* Curl_cookie_add()
@@ -473,7 +496,7 @@ Curl_cookie_add(struct SessionHandle *data,
co->secure = (bool)strequal(ptr, "TRUE");
break;
case 4:
- co->expires = atoi(ptr);
+ co->expires = curlx_strtoofft(ptr, NULL, 10);
break;
case 5:
co->name = strdup(ptr);
@@ -832,7 +855,7 @@ static char *get_netscape_format(const struct Cookie *co)
"%s\t" /* tailmatch */
"%s\t" /* path */
"%s\t" /* secure */
- "%u\t" /* expires */
+ "%" FORMAT_OFF_T "\t" /* expires */
"%s\t" /* name */
"%s", /* value */
/* Make sure all domains are prefixed with a dot if they allow
@@ -842,7 +865,7 @@ static char *get_netscape_format(const struct Cookie *co)
co->tailmatch?"TRUE":"FALSE",
co->path?co->path:"/",
co->secure?"TRUE":"FALSE",
- (unsigned int)co->expires,
+ co->expires,
co->name,
co->value?co->value:"");
}