summaryrefslogtreecommitdiff
path: root/Utilities/cmcurl/lib/cookie.c
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmcurl/lib/cookie.c')
-rw-r--r--Utilities/cmcurl/lib/cookie.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/Utilities/cmcurl/lib/cookie.c b/Utilities/cmcurl/lib/cookie.c
index 8eaedeeb7f..bccf2e8882 100644
--- a/Utilities/cmcurl/lib/cookie.c
+++ b/Utilities/cmcurl/lib/cookie.c
@@ -300,12 +300,11 @@ static char *sanitize_cookie_path(const char *cookie_path)
/* some stupid site sends path attribute with '"'. */
len = strlen(new_path);
if(new_path[0] == '\"') {
- memmove((void *)new_path, (const void *)(new_path + 1), len);
+ memmove(new_path, new_path + 1, len);
len--;
}
if(len && (new_path[len - 1] == '\"')) {
- new_path[len - 1] = 0x0;
- len--;
+ new_path[--len] = 0x0;
}
/* RFC6265 5.2.4 The Path Attribute */
@@ -515,7 +514,7 @@ Curl_cookie_add(struct Curl_easy *data,
return NULL; /* bail out if we're this low on memory */
if(httpheader) {
- /* This line was read off a HTTP-header */
+ /* This line was read off an HTTP-header */
char name[MAX_NAME];
char what[MAX_NAME];
const char *ptr;
@@ -605,9 +604,9 @@ Curl_cookie_add(struct Curl_easy *data,
* only test for names where that can possibly be true.
*/
if(nlen > 3 && name[0] == '_' && name[1] == '_') {
- if(!strncmp("__Secure-", name, 9))
+ if(strncasecompare("__Secure-", name, 9))
co->prefix |= COOKIE_PREFIX__SECURE;
- else if(!strncmp("__Host-", name, 7))
+ else if(strncasecompare("__Host-", name, 7))
co->prefix |= COOKIE_PREFIX__HOST;
}
@@ -780,10 +779,16 @@ Curl_cookie_add(struct Curl_easy *data,
offt = curlx_strtoofft((*co->maxage == '\"')?
&co->maxage[1]:&co->maxage[0], NULL, 10,
&co->expires);
- if(offt == CURL_OFFT_FLOW)
+ switch(offt) {
+ case CURL_OFFT_FLOW:
/* overflow, used max value */
co->expires = CURL_OFF_T_MAX;
- else if(!offt) {
+ break;
+ case CURL_OFFT_INVAL:
+ /* negative or otherwise bad, expire */
+ co->expires = 1;
+ break;
+ case CURL_OFFT_OK:
if(!co->expires)
/* already expired */
co->expires = 1;
@@ -792,6 +797,7 @@ Curl_cookie_add(struct Curl_easy *data,
co->expires = CURL_OFF_T_MAX;
else
co->expires += now;
+ break;
}
}
else if(co->expirestr) {
@@ -864,7 +870,7 @@ Curl_cookie_add(struct Curl_easy *data,
}
else {
/*
- * This line is NOT a HTTP header style line, we do offer support for
+ * This line is NOT an HTTP header style line, we do offer support for
* reading the odd netscape cookies-file format here
*/
char *ptr;
@@ -1258,7 +1264,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
fp = NULL;
}
else {
- fp = fopen(file, FOPEN_READTEXT);
+ fp = fopen(file, "rb");
if(!fp)
infof(data, "WARNING: failed to open cookie file \"%s\"", file);
}