tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William Barker" <wbar...@wilshire.com>
Subject [PATCH] bufferSize overflows in BodyContentImpl TC3.3M2
Date Wed, 04 Apr 2001 00:04:19 GMT
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;



Mime
View raw message