jfarcand 2004/06/07 18:28:52 Modified: jsr154/src/share/javax/servlet/http HttpServlet.java Log: This fixes an ArrayIndexOutOfBoundsException when superclass does not declare any methods (see Bugtraq 4968841). Patch submitted by: Jan Luehe Revision Changes Path 1.8 +16 -24 jakarta-servletapi-5/jsr154/src/share/javax/servlet/http/HttpServlet.java Index: HttpServlet.java =================================================================== RCS file: /home/cvs/jakarta-servletapi-5/jsr154/src/share/javax/servlet/http/HttpServlet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- HttpServlet.java 18 Mar 2004 16:40:35 -0000 1.7 +++ HttpServlet.java 8 Jun 2004 01:28:52 -0000 1.8 @@ -465,36 +465,28 @@ } + private static Method[] getAllDeclaredMethods(Class c) { + if (c.equals(javax.servlet.http.HttpServlet.class)) { + return null; + } - - private Method[] getAllDeclaredMethods(Class c) { - if (c.getName().equals("javax.servlet.http.HttpServlet")) - return null; - - int j=0; - Method[] parentMethods = getAllDeclaredMethods(c.getSuperclass()); - Method[] thisMethods = c.getDeclaredMethods(); + Method[] parentMethods = getAllDeclaredMethods(c.getSuperclass()); + Method[] thisMethods = c.getDeclaredMethods(); - if (parentMethods!=null) { - Method[] allMethods = - new Method[parentMethods.length + thisMethods.length]; - for (int i=0; i<parentMethods.length; i++) { - allMethods[i]=parentMethods[i]; - j=i; - } - j++; - for (int i=j; i<thisMethods.length+j; i++) { - allMethods[i] = thisMethods[i-j]; - } - return allMethods; + if ((parentMethods != null) && (parentMethods.length > 0)) { + Method[] allMethods = + new Method[parentMethods.length + thisMethods.length]; + System.arraycopy(parentMethods, 0, allMethods, 0, + parentMethods.length); + System.arraycopy(thisMethods, 0, allMethods, parentMethods.length, + thisMethods.length); + + thisMethods = allMethods; } + return thisMethods; } - - - - /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]