You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2016/04/06 20:27:47 UTC
[Bug 59282] New: [PATCH] WebappClassLoaderBase.loadClass() throws
StringIndexOutOfBoundsException
https://bz.apache.org/bugzilla/show_bug.cgi?id=59282
Bug ID: 59282
Summary: [PATCH] WebappClassLoaderBase.loadClass() throws
StringIndexOutOfBoundsException
Product: Tomcat 8
Version: 8.0.32
Hardware: PC
OS: Mac OS X 10.1
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: dev@tomcat.apache.org
Reporter: archie@dellroad.org
This exception occurs when you attempt Class.forName("org"):
java.lang.StringIndexOutOfBoundsException: String index out of range: 3
at java.lang.String.charAt(String.java:658) ~[?:1.8.0_72]
at
org.apache.catalina.loader.WebappClassLoaderBase.filter(WebappClassLoaderBase.java:2780)
~[catalina.jar:8.0.32]
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1253)
~[catalina.jar:8.0.32]
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1142)
~[catalina.jar:8.0.32]
at java.lang.Class.forName0(Native Method) ~[?:1.8.0_72]
at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_72]
This is a bug - Class.forName() should never throw
StringIndexOutOfBoundsException. Instead, it should either return the class
named "org" or throw a ClassNotFoundException.
Fix:
--- WebappClassLoaderBase.java.orig 2016-04-06 13:23:39.000000000 -0500
+++ WebappClassLoaderBase.java 2016-04-06 13:25:24.000000000 -0500
@@ -2751,7 +2751,7 @@
return false;
char ch;
- if (name.startsWith("javax")) {
+ if (name.startsWith("javax") && name.length() > 5) {
/* 5 == length("javax") */
ch = name.charAt(5);
if (isClassName && ch == '.') {
@@ -2775,7 +2775,7 @@
return true;
}
}
- } else if (name.startsWith("org")) {
+ } else if (name.startsWith("org") && name.length() > 3) {
/* 3 == length("org") */
ch = name.charAt(3);
if (isClassName && ch == '.') {
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59282] [PATCH] WebappClassLoaderBase.loadClass() throws
StringIndexOutOfBoundsException
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59282
Violeta Georgieva <vi...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Violeta Georgieva <vi...@apache.org> ---
Hi,
Tomcat 8.0.33 is already available so you can switch to it.
Regards,
Violeta
*** This bug has been marked as a duplicate of bug 58999 ***
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org