465053 Prevent gzip buffer overflow on complete

This commit is contained in:
Greg Wilkins 2015-05-22 10:36:46 +10:00
parent 5bde7f34ea
commit 8aeec6803c
1 changed files with 5 additions and 2 deletions

View File

@ -316,8 +316,11 @@ public class GzipHttpOutput extends HttpOutput
BufferUtil.compact(_buffer);
int off=_buffer.arrayOffset()+_buffer.limit();
int len=_buffer.capacity()-_buffer.limit()- (_complete?8:0);
int produced=_deflater.deflate(_buffer.array(),off,len,Deflater.NO_FLUSH);
_buffer.limit(_buffer.limit()+produced);
if (len>0)
{
int produced=_deflater.deflate(_buffer.array(),off,len,Deflater.NO_FLUSH);
_buffer.limit(_buffer.limit()+produced);
}
boolean complete=_deflater.finished();
if (complete)
addTrailer();