cookie: reduce variable scope, add const
This commit is contained in:
parent
8c285a76ee
commit
f88cc654ec
14
lib/cookie.c
14
lib/cookie.c
@ -484,7 +484,7 @@ Curl_cookie_add(struct Curl_easy *data,
|
|||||||
struct CookieInfo *c,
|
struct CookieInfo *c,
|
||||||
bool httpheader, /* TRUE if HTTP header-style line */
|
bool httpheader, /* TRUE if HTTP header-style line */
|
||||||
bool noexpire, /* if TRUE, skip remove_expired() */
|
bool noexpire, /* if TRUE, skip remove_expired() */
|
||||||
char *lineptr, /* first character of the line */
|
const char *lineptr, /* first character of the line */
|
||||||
const char *domain, /* default domain */
|
const char *domain, /* default domain */
|
||||||
const char *path, /* full path used when this cookie is set,
|
const char *path, /* full path used when this cookie is set,
|
||||||
used to get default path for the cookie
|
used to get default path for the cookie
|
||||||
@ -882,7 +882,7 @@ Curl_cookie_add(struct Curl_easy *data,
|
|||||||
if(ptr)
|
if(ptr)
|
||||||
*ptr = 0; /* clear it */
|
*ptr = 0; /* clear it */
|
||||||
|
|
||||||
firstptr = strtok_r(lineptr, "\t", &tok_buf); /* tokenize it on the TAB */
|
firstptr = strtok_r((char *)lineptr, "\t", &tok_buf); /* tokenize on TAB */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now loop through the fields and init the struct we already have
|
* Now loop through the fields and init the struct we already have
|
||||||
@ -1237,24 +1237,20 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
|
|||||||
|
|
||||||
c->running = FALSE; /* this is not running, this is init */
|
c->running = FALSE; /* this is not running, this is init */
|
||||||
if(fp) {
|
if(fp) {
|
||||||
char *lineptr;
|
|
||||||
bool headerline;
|
|
||||||
|
|
||||||
line = malloc(MAX_COOKIE_LINE);
|
line = malloc(MAX_COOKIE_LINE);
|
||||||
if(!line)
|
if(!line)
|
||||||
goto fail;
|
goto fail;
|
||||||
while(Curl_get_line(line, MAX_COOKIE_LINE, fp)) {
|
while(Curl_get_line(line, MAX_COOKIE_LINE, fp)) {
|
||||||
|
char *lineptr = line;
|
||||||
|
bool headerline = FALSE;
|
||||||
if(checkprefix("Set-Cookie:", line)) {
|
if(checkprefix("Set-Cookie:", line)) {
|
||||||
/* This is a cookie line, get it! */
|
/* This is a cookie line, get it! */
|
||||||
lineptr = &line[11];
|
lineptr = &line[11];
|
||||||
headerline = TRUE;
|
headerline = TRUE;
|
||||||
}
|
|
||||||
else {
|
|
||||||
lineptr = line;
|
|
||||||
headerline = FALSE;
|
|
||||||
}
|
|
||||||
while(*lineptr && ISBLANK(*lineptr))
|
while(*lineptr && ISBLANK(*lineptr))
|
||||||
lineptr++;
|
lineptr++;
|
||||||
|
}
|
||||||
|
|
||||||
Curl_cookie_add(data, c, headerline, TRUE, lineptr, NULL, NULL, TRUE);
|
Curl_cookie_add(data, c, headerline, TRUE, lineptr, NULL, NULL, TRUE);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,6 @@ struct CookieInfo {
|
|||||||
|
|
||||||
- At least 4096 bytes per cookie (as measured by the sum of the length of
|
- At least 4096 bytes per cookie (as measured by the sum of the length of
|
||||||
the cookie's name, value, and attributes).
|
the cookie's name, value, and attributes).
|
||||||
|
|
||||||
In the 6265bis draft document section 5.4 it is phrased even stronger: "If
|
In the 6265bis draft document section 5.4 it is phrased even stronger: "If
|
||||||
the sum of the lengths of the name string and the value string is more than
|
the sum of the lengths of the name string and the value string is more than
|
||||||
4096 octets, abort these steps and ignore the set-cookie-string entirely."
|
4096 octets, abort these steps and ignore the set-cookie-string entirely."
|
||||||
@ -109,7 +108,7 @@ struct Curl_easy;
|
|||||||
|
|
||||||
struct Cookie *Curl_cookie_add(struct Curl_easy *data,
|
struct Cookie *Curl_cookie_add(struct Curl_easy *data,
|
||||||
struct CookieInfo *c, bool header,
|
struct CookieInfo *c, bool header,
|
||||||
bool noexpiry, char *lineptr,
|
bool noexpiry, const char *lineptr,
|
||||||
const char *domain, const char *path,
|
const char *domain, const char *path,
|
||||||
bool secure);
|
bool secure);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user