Skip to content

Commit b5d193a

Browse files
author
Justin Erenkrantz
committed
Fix bug in mod_usertrack when no CookieName is set.
PR: 24483 Submitted by: Manni Wood <manniwood planet-save.com> Reviewed by: Cliff Woolley, Justin Erenkrantz, Sander Striker git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@102892 13f79535-47bb-0310-9956-ffa450edef68
1 parent c7f025d commit b5d193a

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Changes with Apache 2.0.49
22

3+
*) Fix bug in mod_usertrack when no CookieName is set. PR 24483.
4+
[Manni Wood <manniwood planet-save.com>]
5+
36
*) Fix some piped log problems: bogus "piped log program '(null)'
47
failed" messages during restart and problem with the logger
58
respawning again after Apache is stopped. PR 21648, PR 24805.

modules/metadata/mod_usertrack.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ static void make_cookie(request_rec *r)
156156
* which has three subexpressions, $0..$2 */
157157
#define NUM_SUBS 3
158158

159+
static void set_and_comp_regexp(cookie_dir_rec *dcfg,
160+
apr_pool_t *p,
161+
const char *cookie_name)
162+
{
163+
/* The goal is to end up with this regexp,
164+
* ^cookie_name=([^;]+)|;[\t]+cookie_name=([^;]+)
165+
* with cookie_name obviously substituted either
166+
* with the real cookie name set by the user in httpd.conf, or with the
167+
* default COOKIE_NAME. */
168+
dcfg->regexp_string = apr_pstrcat(p, "^", cookie_name, "=([^;]+)|;[ \t]+", cookie_name, "=([^;]+)", NULL);
169+
170+
dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, REG_EXTENDED);
171+
}
172+
159173
static int spot_cookie(request_rec *r)
160174
{
161175
cookie_dir_rec *dcfg = ap_get_module_config(r->per_dir_config,
@@ -214,6 +228,11 @@ static void *make_cookie_dir(apr_pool_t *p, char *d)
214228
dcfg->cookie_domain = NULL;
215229
dcfg->style = CT_UNSET;
216230
dcfg->enabled = 0;
231+
232+
/* In case the user does not use the CookieName directive,
233+
* we need to compile the regexp for the default cookie name. */
234+
set_and_comp_regexp(dcfg, p, COOKIE_NAME);
235+
217236
return dcfg;
218237
}
219238

@@ -299,18 +318,10 @@ static const char *set_cookie_name(cmd_parms *cmd, void *mconfig,
299318
{
300319
cookie_dir_rec *dcfg = (cookie_dir_rec *) mconfig;
301320

302-
/* The goal is to end up with this regexp,
303-
* ^cookie_name=([^;]+)|;[ \t]+cookie_name=([^;]+)
304-
* with cookie_name
305-
* obviously substituted with the real cookie name set by the
306-
* user in httpd.conf. */
307-
dcfg->regexp_string = apr_pstrcat(cmd->pool, "^", name,
308-
"=([^;]+)|;[ \t]+", name,
309-
"=([^;]+)", NULL);
310-
311321
dcfg->cookie_name = apr_pstrdup(cmd->pool, name);
312322

313-
dcfg->regexp = ap_pregcomp(cmd->pool, dcfg->regexp_string, REG_EXTENDED);
323+
set_and_comp_regexp(dcfg, cmd->pool, name);
324+
314325
if (dcfg->regexp == NULL) {
315326
return "Regular expression could not be compiled.";
316327
}

0 commit comments

Comments
 (0)