Description: fix directory traversal via incorrect ServetContext attribute
Origin: upstream, http://svn.apache.org/viewvc?view=revision&revision=1022560
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=612257
Bug-ubuntu: https://bugs.launchpad.net/ubuntu/+source/tomcat6/+bug/717396

Index: tomcat6-6.0.24/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- tomcat6-6.0.24.orig/java/org/apache/catalina/core/StandardContext.java	2009-12-23 11:31:31.000000000 -0500
+++ tomcat6-6.0.24/java/org/apache/catalina/core/StandardContext.java	2011-03-24 11:08:02.543072691 -0400
@@ -5146,11 +5146,11 @@
         dir.mkdirs();
 
         // Set the appropriate servlet context attribute
-        getServletContext().setAttribute(Globals.WORK_DIR_ATTR, dir);
-        if (getServletContext() instanceof ApplicationContext)
-            ((ApplicationContext) getServletContext()).setAttributeReadOnly
-                (Globals.WORK_DIR_ATTR);
-
+        if (context == null) {
+            getServletContext();
+        }
+        context.setAttribute(Globals.WORK_DIR_ATTR, dir);
+        context.setAttributeReadOnly(Globals.WORK_DIR_ATTR);
     }
 
 
