httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/metadata mod_usertrack.c
Date Sat, 10 Apr 2004 13:17:15 GMT
nd          2004/04/10 06:17:15

  Modified:    .        CHANGES
               modules/metadata mod_usertrack.c
  Log:
  escape the cookie_name before pasting into the regexp.
  
  Revision  Changes    Path
  1.1450    +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1449
  retrieving revision 1.1450
  diff -u -u -r1.1449 -r1.1450
  --- CHANGES	9 Apr 2004 00:56:25 -0000	1.1449
  +++ CHANGES	10 Apr 2004 13:17:14 -0000	1.1450
  @@ -2,6 +2,9 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) mod_usertrack: Escape the cookie name before pasting into the
  +     regexp.  [André Malo]
  +
     *) Enable special ErrorDocument value 'default' which restores the
        canned server response for the scope of the directive.
        [Geoffrey Young]
  
  
  
  1.51      +33 -1     httpd-2.0/modules/metadata/mod_usertrack.c
  
  Index: mod_usertrack.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_usertrack.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -u -r1.50 -r1.51
  --- mod_usertrack.c	10 Apr 2004 12:36:34 -0000	1.50
  +++ mod_usertrack.c	10 Apr 2004 13:17:15 -0000	1.51
  @@ -160,12 +160,44 @@
                                   apr_pool_t *p,
                                   const char *cookie_name)
   {
  +    int danger_chars = 0;
  +    const char *sp = 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);
  +
  +    /* Anyway, we need to escape the cookie_name before pasting it
  +     * into the regex
  +     */
  +    while (*sp) {
  +        if (!apr_isalnum(*sp)) {
  +            ++danger_chars;
  +        }
  +        ++sp;
  +    }
  +
  +    if (danger_chars) {
  +        char *cp;
  +        cp = apr_palloc(p, sp - cookie_name + danger_chars + 1); /* 1 == \0 */
  +        sp = cookie_name;
  +        cookie_name = cp;
  +        while (*sp) {
  +            if (!apr_isalnum(*sp)) {
  +                *cp++ = '\\';
  +            }
  +            *cp++ = *sp++;
  +        }
  +        *cp = '\0';
  +    }
  +
  +    dcfg->regexp_string = apr_pstrcat(p, "^",
  +                                      cookie_name,
  +                                      "=([^;,]+)|[;,][ \t]*",
  +                                      cookie_name,
  +                                      "=([^;,]+)", NULL);
   
       dcfg->regexp = ap_pregcomp(p, dcfg->regexp_string, REG_EXTENDED);
   }
  
  
  

Mime
View raw message