Author: markt
Date: Sat Jun 23 08:00:51 2007
New Revision: 550048

URL: http://svn.apache.org/viewvc?view=rev&rev=550048
Log:
Port fix for bug 42547. Fix NPE when a ResourceLink tries to override an 
env-entry.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java?view=diff&rev=550048&r1=550047&r2=550048
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/deploy/NamingResources.java 
Sat Jun 23 08:00:51 2007
@@ -25,6 +25,8 @@
 import java.util.Hashtable;
 import java.io.Serializable;
 
+import org.apache.catalina.ServerFactory;
+
 
 /**
  * Holds and manages the naming resources defined in the J2EE Enterprise 
@@ -191,9 +193,27 @@
     public void addEnvironment(ContextEnvironment environment) {
 
         if (entries.containsKey(environment.getName())) {
-            if (findEnvironment(environment.getName()).getOverride()) {
-                removeEnvironment(environment.getName());
+            ContextEnvironment ce = findEnvironment(environment.getName());
+            ContextResourceLink rl = findResourceLink(environment.getName());
+            if (ce != null) {
+                if (ce.getOverride()) {
+                    removeEnvironment(environment.getName());
+                } else {
+                    return;
+                }
+            } else if (rl != null) {
+                // Link. Need to look at the global resources
+                NamingResources global =
+                    ServerFactory.getServer().getGlobalNamingResources();
+                if (global.findEnvironment(rl.getGlobal()) != null) {
+                    if (global.findEnvironment(rl.getGlobal()).getOverride()) {
+                        removeResourceLink(environment.getName());
+                    } else {
+                        return;
+                    }
+                }
             } else {
+                // It exists but it isn't an env or a res link...
                 return;
             }
         }

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?view=diff&rev=550048&r1=550047&r2=550048
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Sat Jun 23 08:00:51 2007
@@ -51,6 +51,10 @@
         Fix XSS security vulnerability (CVE-2007-2450) in the Manager and Host
         Manager. Reported by Daiki Fukumori. (markt)
       </fix>
+      <fix>
+        <bug>42547</bug>: Fix NPE when a ResourceLink in context.xml tries to
+        override an env-entry in web.xml.
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to