luehe       2004/03/02 09:34:46

  Modified:    catalina/src/share/org/apache/coyote/tomcat5
                        CoyoteRequestFacade.java
  Log:
  Clone returned arrays only if there is a security manager in place
  
  Revision  Changes    Path
  1.6       +18 -10    
jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteRequestFacade.java
  
  Index: CoyoteRequestFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/coyote/tomcat5/CoyoteRequestFacade.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CoyoteRequestFacade.java  2 Mar 2004 00:35:46 -0000       1.5
  +++ CoyoteRequestFacade.java  2 Mar 2004 17:34:46 -0000       1.6
  @@ -278,19 +278,23 @@
   
   
       public String[] getParameterValues(String name) {
  +
           String[] ret = null;
   
  +        /*
  +         * Clone the returned array only if there is a security manager
  +         * in place, so that performance won't suffer in the nonsecure case
  +         */
           if (System.getSecurityManager() != null){
               ret = (String[]) AccessController.doPrivileged(
                   new GetParameterValuePrivilegedAction(name));
  +            if (ret != null) {
  +                ret = (String[]) ret.clone();
  +         }
           } else {
               ret = request.getParameterValues(name);
           }
   
  -        if (ret != null) {
  -            ret = (String[]) ret.clone();
  -     }
  -
           return ret;
       }
   
  @@ -397,20 +401,24 @@
   
   
       public Cookie[] getCookies() {
  +
           Cookie[] ret = null;
   
  +        /*
  +         * Clone the returned array only if there is a security manager
  +         * in place, so that performance won't suffer in the nonsecure case
  +         */
           if (System.getSecurityManager() != null){
               ret = (Cookie[])AccessController.doPrivileged(
                   new GetCookiesPrivilegedAction());
  +            if (ret != null) {
  +                ret = (Cookie[]) ret.clone();
  +            }
           } else {
               ret = request.getCookies();
           }
   
  -        if (ret != null) {
  -            ret = (Cookie[]) ret.clone();
  -        }
  -
  -        return ret;  
  +        return ret;
       }
   
   
  
  
  

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

Reply via email to