Author: toad
Date: 2007-08-15 13:22:03 +0000 (Wed, 15 Aug 2007)
New Revision: 14697
Modified:
trunk/freenet/src/freenet/support/compress/GzipCompressor.java
Log:
Read no more than the requested number of bytes in decompress()
Modified: trunk/freenet/src/freenet/support/compress/GzipCompressor.java
===================================================================
--- trunk/freenet/src/freenet/support/compress/GzipCompressor.java
2007-08-15 13:21:03 UTC (rev 14696)
+++ trunk/freenet/src/freenet/support/compress/GzipCompressor.java
2007-08-15 13:22:03 UTC (rev 14697)
@@ -67,14 +67,14 @@
byte[] buffer = new byte[4096];
while(true) {
int l = (int) Math.min(buffer.length, maxLength -
written);
- int x = gis.read(buffer, 0, buffer.length);
+ int x = gis.read(buffer, 0, l);
if(l < x) {
Logger.normal(this, "l="+l+", x="+x+",
written="+written+", maxLength="+maxLength+" throwing a
CompressionOutputSizeException");
if(maxCheckSizeBytes > 0) {
written += x;
while(true) {
l = (int)
Math.min(buffer.length, maxLength + maxCheckSizeBytes - written);
- x = gis.read(buffer, 0,
buffer.length);
+ x = gis.read(buffer, 0, l);
if(x <= -1) throw new
CompressionOutputSizeException(written);
if(x == 0) throw new
IOException("Returned zero from read()");
written += x;