mirror of
https://github.com/curl/curl.git
synced 2026-08-04 13:46:26 +03:00
cookie: don't treat the leading slash as trailing
If there is only a leading slash in the path, keep that. Also add an assert to make sure the path is never blank. Reported-by: Google Big Sleep Closes #18266
This commit is contained in:
parent
f6f62933e9
commit
c6ae07c6a5
1 changed files with 6 additions and 5 deletions
11
lib/cookie.c
11
lib/cookie.c
|
|
@ -296,9 +296,9 @@ static char *sanitize_cookie_path(const char *cookie_path)
|
|||
/* Let cookie-path be the default-path. */
|
||||
return strdup("/");
|
||||
|
||||
/* remove trailing slash */
|
||||
/* remove trailing slash when path is non-empty */
|
||||
/* convert /hoge/ to /hoge */
|
||||
if(len && cookie_path[len - 1] == '/')
|
||||
if(len > 1 && cookie_path[len - 1] == '/')
|
||||
len--;
|
||||
|
||||
return Curl_memdup0(cookie_path, len);
|
||||
|
|
@ -965,7 +965,7 @@ replace_existing(struct Curl_easy *data,
|
|||
clist->spath && co->spath && /* both have paths */
|
||||
clist->secure && !co->secure && !secure) {
|
||||
size_t cllen;
|
||||
const char *sep;
|
||||
const char *sep = NULL;
|
||||
|
||||
/*
|
||||
* A non-secure cookie may not overlay an existing secure cookie.
|
||||
|
|
@ -974,8 +974,9 @@ replace_existing(struct Curl_easy *data,
|
|||
* "/loginhelper" is ok.
|
||||
*/
|
||||
|
||||
sep = strchr(clist->spath + 1, '/');
|
||||
|
||||
DEBUGASSERT(clist->spath[0]);
|
||||
if(clist->spath[0])
|
||||
sep = strchr(clist->spath + 1, '/');
|
||||
if(sep)
|
||||
cllen = sep - clist->spath;
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue