You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by William Barker <wb...@wilshire.com> on 2001/04/04 02:04:19 UTC

[PATCH] bufferSize overflows in BodyContentImpl TC3.3M2

The bufferSize variable in BodyContentImpl is declared as an int.  This
results in an integer overflow very quickly for even moderately big output.
(Think displaying the results of a SQL table as a HTML table).  I imagine
that the ultimate solution will be to declare it as a long, but in the mean
time...
*** BodyContentImpl.java.orig   Tue Apr  3 16:46:37 2001
--- BodyContentImpl.java        Tue Apr  3 16:47:15 2001
***************
*** 110,119 ****
          char[] tmp = null;

        //XXX Should it be multiple of DEFAULT_BUFFER_SIZE??
!
        if (len <= Constants.DEFAULT_BUFFER_SIZE) {
            tmp = new char [bufferSize + Constants.DEFAULT_BUFFER_SIZE];
!           bufferSize = bufferSize * 2;
        } else {
            tmp = new char [bufferSize + len];
            bufferSize += len;
--- 110,119 ----
          char[] tmp = null;

        //XXX Should it be multiple of DEFAULT_BUFFER_SIZE??
!         len += Constants.DEFAULT_BUFFER_SIZE -
(len%Constants.DEFAULT_BUFFER_SIZE);
        if (len <= Constants.DEFAULT_BUFFER_SIZE) {
            tmp = new char [bufferSize + Constants.DEFAULT_BUFFER_SIZE];
!             bufferSize += Constants.DEFAULT_BUFFER_SIZE;
        } else {
            tmp = new char [bufferSize + len];
            bufferSize += len;