]> granicus.if.org Git - apache/commitdiff
Fix bug in mod_usertrack when no CookieName is set.
authorJustin Erenkrantz <jerenkrantz@apache.org>
Mon, 8 Mar 2004 23:27:31 +0000 (23:27 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Mon, 8 Mar 2004 23:27:31 +0000 (23:27 +0000)
PR: 24483
Submitted by: Manni Wood <manniwood planet-save.com>
Reviewed by: Cliff Woolley, Jim Jagielski

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@102890 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/metadata/mod_usertrack.c

diff --git a/CHANGES b/CHANGES
index 314e7e3fa26b4f6c81268f398cbc438ce04d04a8..648e91a9838264d63c4708d36b792f45b9c62a19 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) Fix bug in mod_usertrack when no CookieName is set.  PR 24483.
+     [Manni Wood <manniwood planet-save.com>]
+
   *) Remove compile-time length limit on request strings. Length is
      now enforced solely with the LimitRequestLine config directive.
      [Paul J. Reder]
index 7408e79b3c5f34da5ec105a82ae489826b356066..4c4f1447eb6b04fe0677e707903eae429d4b7ffb 100644 (file)
@@ -156,6 +156,20 @@ static void make_cookie(request_rec *r)
  * which has three subexpressions, $0..$2 */
 #define NUM_SUBS 3
 
+static void set_and_comp_regexp(cookie_dir_rec *dcfg,
+                                apr_pool_t *p,
+                                const char *cookie_name)
+{
+    /* The goal is to end up with this regexp,
+     * ^cookie_name=([^;]+)|;[\t]+cookie_name=([^;]+)
+     * with cookie_name obviously substituted either
+     * with the real cookie name set by the user in httpd.conf, or with the
+     * default COOKIE_NAME. */
+    dcfg->regexp_string = apr_pstrcat(p, "^", cookie_name, "=([^;]+)|;[ \t]+", cookie_name, "=([^;]+)", NULL);
+
+    dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, REG_EXTENDED);
+}
+
 static int spot_cookie(request_rec *r)
 {
     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)
     dcfg->cookie_domain = NULL;
     dcfg->style = CT_UNSET;
     dcfg->enabled = 0;
+
+    /* In case the user does not use the CookieName directive,
+     * we need to compile the regexp for the default cookie name. */
+    set_and_comp_regexp(dcfg, p, COOKIE_NAME);
+
     return dcfg;
 }
 
@@ -299,18 +318,10 @@ static const char *set_cookie_name(cmd_parms *cmd, void *mconfig,
 {
     cookie_dir_rec *dcfg = (cookie_dir_rec *) mconfig;
 
-    /* The goal is to end up with this regexp,
-     * ^cookie_name=([^;]+)|;[ \t]+cookie_name=([^;]+)
-     * with cookie_name
-     * obviously substituted with the real cookie name set by the
-     * user in httpd.conf. */
-    dcfg->regexp_string = apr_pstrcat(cmd->pool, "^", name,
-                                      "=([^;]+)|;[ \t]+", name,
-                                      "=([^;]+)", NULL);
-
     dcfg->cookie_name = apr_pstrdup(cmd->pool, name);
 
-    dcfg->regexp = ap_pregcomp(cmd->pool, dcfg->regexp_string, REG_EXTENDED);
+    set_and_comp_regexp(dcfg, cmd->pool, name);
+
     if (dcfg->regexp == NULL) {
         return "Regular expression could not be compiled.";
     }