423392 Fix buffer overflow in AsyncGzipFilter

This commit is contained in:
Greg Wilkins 2014-04-07 12:32:46 +10:00
parent 4688c10361
commit 086e39f6db
1 changed files with 1 additions and 25 deletions

View File

@ -115,37 +115,13 @@ public class GzipHttpOutput extends HttpOutput
private void gzip(ByteBuffer content, boolean complete, final Callback callback)
{
if (content.hasRemaining())
if (content.hasRemaining() || complete)
{
if (content.hasArray())
new GzipArrayCB(content,complete,callback).iterate();
else
new GzipBufferCB(content,complete,callback).iterate();
}
else if (complete)
{
_deflater.finish();
int produced=_deflater.deflate(_buffer.array(),_buffer.arrayOffset()+_buffer.limit(),_buffer.capacity()-_buffer.limit(),Deflater.NO_FLUSH);
_buffer.limit(_buffer.limit()+produced);
addTrailer();
superWrite(_buffer,complete,new Callback()
{
@Override
public void succeeded()
{
getHttpChannel().getByteBufferPool().release(_buffer);
_buffer=null;
callback.succeeded();
}
@Override
public void failed(Throwable x)
{
callback.failed(x);
}
});
}
}
protected void commit(ByteBuffer content, boolean complete, Callback callback)