#! /bin/sh /usr/share/dpatch/dpatch-run
# Description: fix denial of service and possible code execution via
#  type field modification within a scoreboard shared memory segment
# Origin: upstream, http://svn.apache.org/viewvc?view=revision&revision=1231058

@DPATCH@
diff -urNad '--exclude=CVS' '--exclude=.svn' '--exclude=.git' '--exclude=.arch' '--exclude=.hg' '--exclude=_darcs' '--exclude=.bzr' apache2-2.2.17~/server/scoreboard.c apache2-2.2.17/server/scoreboard.c
--- apache2-2.2.17~/server/scoreboard.c	2010-10-07 12:56:54.000000000 -0400
+++ apache2-2.2.17/server/scoreboard.c	2012-02-14 10:02:05.192419440 -0500
@@ -42,6 +42,8 @@
 AP_DECLARE_DATA int ap_extended_status = 0;
 AP_DECLARE_DATA int ap_mod_status_reqtail = 0;
 
+static ap_scoreboard_e scoreboard_type;
+
 #if APR_HAS_SHARED_MEMORY
 
 #include "apr_shm.h"
@@ -250,7 +252,7 @@
     if (ap_scoreboard_image == NULL) {
         return APR_SUCCESS;
     }
-    if (ap_scoreboard_image->global->sb_type == SB_SHARED) {
+    if (scoreboard_type == SB_SHARED) {
         ap_cleanup_shared_mem(NULL);
     }
     else {
@@ -312,7 +314,7 @@
         ap_init_scoreboard(sb_mem);
     }
 
-    ap_scoreboard_image->global->sb_type = sb_type;
+    ap_scoreboard_image->global->sb_type = scoreboard_type = sb_type;
     ap_scoreboard_image->global->running_generation = 0;
     ap_scoreboard_image->global->restart_time = apr_time_now();
 
