Author: markt Date: Sun Mar 2 15:56:34 2014 New Revision: 1573321 URL: http://svn.apache.org/r1573321 Log: Avoid internal NullPointerExceptions if a resource is requested from outside the web application root.
Modified: tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java?rev=1573321&r1=1573320&r2=1573321&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java (original) +++ tomcat/trunk/java/org/apache/catalina/webresources/StandardRoot.java Sun Mar 2 15:56:34 2014 @@ -117,6 +117,9 @@ public class StandardRoot extends Lifecy if (validate) { path = validate(path); } + if (path == null) { + return new String[] {}; + } // Set because we don't want duplicates // LinkedHashSet to retain the order. It is the order of the @@ -140,6 +143,9 @@ public class StandardRoot extends Lifecy @Override public Set<String> listWebAppPaths(String path) { path = validate(path); + if (path == null) { + return null; + } // Set because we don't want duplicates HashSet<String> result = new HashSet<>(); @@ -159,6 +165,9 @@ public class StandardRoot extends Lifecy @Override public boolean mkdir(String path) { path = validate(path); + if (path == null) { + return false; + } if (preResourceExists(path)) { return false; @@ -170,6 +179,9 @@ public class StandardRoot extends Lifecy @Override public boolean write(String path, InputStream is, boolean overwrite) { path = validate(path); + if (path == null) { + return false; + } if (!overwrite && preResourceExists(path)) { return false; @@ -198,6 +210,9 @@ public class StandardRoot extends Lifecy if (validate) { path = validate(path); } + if (path == null) { + return null; + } if (isCachingAllowed()) { return cache.getResource(path, useClassLoaderResources); @@ -280,6 +295,9 @@ public class StandardRoot extends Lifecy private WebResource[] getResources(String path, boolean useClassLoaderResources) { path = validate(path); + if (path == null) { + return new WebResource[] {}; + } ArrayList<WebResource> result = new ArrayList<>(); for (ArrayList<WebResourceSet> list : allResources) { @@ -309,6 +327,9 @@ public class StandardRoot extends Lifecy if (validate) { path = validate(path); } + if (path == null) { + return new WebResource[] {}; + } String[] resources = list(path, false); WebResource[] result = new WebResource[resources.length]; Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1573321&r1=1573320&r2=1573321&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Sun Mar 2 15:56:34 2014 @@ -74,6 +74,10 @@ elements and attributes supported by the Servlet version of the merged file. (markt) </fix> + <fix> + Avoid internal <code>NullPointerException</code>s if a resource is + requested from outside the web application root. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org