Commit 094f3d4f authored by ale's avatar ale
Browse files

do not destroy the Cookie header when parsing it

parent 7f8c4640
......@@ -254,17 +254,18 @@ static int is_valid_redir(request_rec *r,
* @return the cookie value, or an empty string if no cookie was found.
static char *get_cookie(request_rec *r, const char *cookie_name) {
char *rv = NULL, *cookie, *tokenizerCtx = NULL;
int cookie_name_len;
char *rv = NULL, *cookies, *cookie, *tokenizerCtx = NULL;
int cookie_name_len = strlen(cookie_name);
// How do we know this is writable? TODO: make a copy.
char *cookies_c = (char *)apr_table_get(r->headers_in, "Cookie");
const char *cookies_c = apr_table_get(r->headers_in, "Cookie");
if (cookies_c == NULL) {
return NULL;
cookie_name_len = strlen(cookie_name);
cookie = apr_strtok(cookies_c, ";", &tokenizerCtx);
// Make a copy of the Cookie header so that we can modify it
// (tokenization is destructive).
cookies = apr_pstrdup(r->pool, cookies_c);
cookie = apr_strtok(cookies, ";", &tokenizerCtx);
do {
while (cookie != NULL && *cookie == ' ')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment