Author: toad
Date: 2006-09-27 23:07:45 +0000 (Wed, 27 Sep 2006)
New Revision: 10528
Modified:
trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
Log:
Fix ArrayIndexOutOfBoundsException again??
Modified: trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
===================================================================
--- trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
2006-09-27 22:54:37 UTC (rev 10527)
+++ trunk/freenet/src/freenet/support/io/LineReadingInputStream.java
2006-09-27 23:07:45 UTC (rev 10528)
@@ -22,7 +22,7 @@
if(maxLength < bufferSize)
bufferSize = maxLength;
if(buf == null)
- buf = new byte[bufferSize];
+ buf = new byte[Math.max(Math.min(128,maxLength),
Math.min(1024, bufferSize))];
int ctr = 0;
while(true) {
int x = read();
@@ -36,8 +36,8 @@
if(buf[ctr-1] == '\r') ctr--;
return new String(buf, 0, ctr, utf ? "UTF-8" :
"ISO-8859-1");
}
+ if(ctr >= maxLength) throw new TooLongException();
if(ctr >= buf.length) {
- if(buf.length == maxLength) throw new
TooLongException();
byte[] newBuf = new byte[Math.min(buf.length *
2, maxLength)];
System.arraycopy(buf, 0, newBuf, 0, buf.length);
buf = newBuf;