#! /bin/sh /usr/share/dpatch/dpatch-run
# Description: fix denial of service via invalid cookie
# Origin: upstream, http://svn.apache.org/viewvc?view=revision&revision=1227292
# Bug: https://issues.apache.org/bugzilla/show_bug.cgi?id=52256

@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' apache2-2.2.17~/modules/loggers/mod_log_config.c apache2-2.2.17/modules/loggers/mod_log_config.c
--- apache2-2.2.17~/modules/loggers/mod_log_config.c	2010-08-24 02:41:38.000000000 -0400
+++ apache2-2.2.17/modules/loggers/mod_log_config.c	2012-02-14 10:01:52.352419114 -0500
@@ -524,19 +524,21 @@
 
         while ((cookie = apr_strtok(cookies, ";", &last1))) {
             char *name = apr_strtok(cookie, "=", &last2);
-            char *value;
-            apr_collapse_spaces(name, name);
+            if (name) {
+                char *value;
+                apr_collapse_spaces(name, name);
 
-            if (!strcasecmp(name, a) && (value = apr_strtok(NULL, "=", &last2))) {
-                char *last;
-                value += strspn(value, " \t");  /* Move past leading WS */
-                last = value + strlen(value) - 1;
-                while (last >= value && apr_isspace(*last)) {
-                   *last = '\0';
-                   --last;
-                }
+                if (!strcasecmp(name, a) && (value = apr_strtok(NULL, "=", &last2))) {
+                    char *last;
+                    value += strspn(value, " \t");  /* Move past leading WS */
+                    last = value + strlen(value) - 1;
+                    while (last >= value && apr_isspace(*last)) {
+                       *last = '\0';
+                       --last;
+                    }
 
-                return ap_escape_logitem(r->pool, value);
+                    return ap_escape_logitem(r->pool, value);
+                }
             }
             cookies = NULL;
         }
