remm        2002/10/10 08:33:29

  Modified:    jasper2/src/share/org/apache/jasper/runtime
                        BodyContentImpl.java
  Log:
  - Fix array out of bounds. After calling setWriter, the bufferSize doesn't match
    the actual buffer size (which is a problem when you need to resize the buffer).
    This was introduced in rev 1.5 by Jan (and I don't understand what that
    saveBufferSize is).
  
  Revision  Changes    Path
  1.7       +16 -13    
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/BodyContentImpl.java
  
  Index: BodyContentImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/runtime/BodyContentImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BodyContentImpl.java      3 Oct 2002 23:50:11 -0000       1.6
  +++ BodyContentImpl.java      10 Oct 2002 15:33:29 -0000      1.7
  @@ -594,7 +594,7 @@
        bodyContent.writeOut (new PrintWriter (System.out));
       }
   
  -    /*
  +    /**
        * Sets the writer to which all output is written.
        */
       void setWriter(Writer writer) {
  @@ -614,25 +614,28 @@
        if (closed) throw new IOException("Stream closed");
       }
   
  -    /*
  +    /**
        * Reallocates buffer since the spec requires it to be unbounded.
        */
  -    private void reAllocBuff (int len) {
  +    private void reAllocBuff(int len) {
   
  -     char[] tmp = null;
  +        if (bufferSize + len <= cb.length) {
  +            bufferSize = cb.length;
  +            return;
  +        }
  +
  +        if (len < Constants.DEFAULT_TAG_BUFFER_SIZE) {
  +            len = Constants.DEFAULT_TAG_BUFFER_SIZE;
  +        }
   
  -     //XXX Should it be multiple of DEFAULT_TAG_BUFFER_SIZE?
  -
  -     if (len <= Constants.DEFAULT_TAG_BUFFER_SIZE) {
  -         tmp = new char [bufferSize + Constants.DEFAULT_TAG_BUFFER_SIZE];
  -         bufferSize += Constants.DEFAULT_TAG_BUFFER_SIZE;
  -     } else {
  -         tmp = new char [bufferSize + len];
  -         bufferSize += len;
  -     }
  +        bufferSize = cb.length + len;
  +        char[] tmp = new char[bufferSize];
   
        System.arraycopy(cb, 0, tmp, 0, cb.length);
        cb = tmp;
        tmp = null;
  +
       }
  +
  +
   }
  
  
  

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

Reply via email to