]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fold in backport of 2.0 fix for mod_usertrack core dump
authorJim Jagielski <jim@apache.org>
Tue, 13 Jan 2004 13:47:34 +0000 (13:47 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 13 Jan 2004 13:47:34 +0000 (13:47 +0000)
when enabled but no explicit CookieName is set.

PR: 24483(Bugz)
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@102319 13f79535-47bb-0310-9956-ffa450edef68

src/CHANGES
src/modules/standard/mod_usertrack.c

index 8cd63587fbe3455dc85f263608badedc1653412d..0fe39a9d6108208fa1b6925acfe7bc219a17644e 100644 (file)
@@ -1,5 +1,9 @@
 Changes with Apache 1.3.30
 
+  *) Fix bug causing core dump when using CookieTracking without
+     specifying a CookieName directly. Bugz# 24483.
+     [Manni Wood <manniwood planet-save.com>, Jim Jagielski (backport)]
+
   *) Fix RewriteBase directive to not add double slashes.  [AndrĂ© Malo]
 
   *) mod_rewrite: In external rewrite maps lookup keys containing
index 492a9778df3c6cfaf1e84dd780a09c582e1e4769..92efa0bb0383089241c0eb5b210b1af40b5333c7 100644 (file)
@@ -286,10 +286,29 @@ static void make_cookie(request_rec *r)
     return;
 }
 
-/* dcfg->regexp is "^cookie_name=([^;]+)|;[ \t]+cookie_name=([^;]+)",
- * which has three subexpressions, $0..$2 */
+/*
+ * dcfg->regexp is "^cookie_name=([^;]+)|;[ \t]+cookie_name=([^;]+)",
+ * which has three subexpressions, $0..$2
+ */
 #define NUM_SUBS 3
 
+static void set_and_comp_regexp(cookie_dir_rec *dcfg, 
+                                pool *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 = ap_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,
@@ -352,6 +371,11 @@ static void *make_cookie_dir(pool *p, char *d)
     dcfg->style = CT_UNSET;
     dcfg->format = CF_NORMAL;
     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;
 }
 
@@ -436,18 +460,10 @@ static const char *set_cookie_name(cmd_parms *cmd, void *mconfig, char *name)
 {
     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 = ap_pstrcat(cmd->pool, "^", name, 
-                                     "=([^;]+)|;[ \t]+", name, 
-                                     "=([^;]+)", NULL);
-
     dcfg->cookie_name = ap_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.";
     }