[#755] SPDY: fix header block values truncation in decompression

This commit is contained in:
Norman Maurer 2012-11-20 20:09:59 +01:00
parent ff14feeb54
commit 2adebc4c54
3 changed files with 10 additions and 4 deletions

View File

@ -527,8 +527,13 @@ public class SpdyFrameDecoder extends ByteToMessageDecoder<Object> {
return true;
}
// Perhaps last call to decode filled output buffer
headerBlockDecompressor.decode(decompressed);
return decompressed.readableBytes() >= bytes;
int numBytes;
boolean done;
do {
numBytes = headerBlockDecompressor.decode(decompressed);
done = decompressed.readableBytes() >= bytes;
} while (!done && numBytes > 0);
return done;
}
private int readLengthField() {

View File

@ -24,6 +24,6 @@ abstract class SpdyHeaderBlockDecompressor {
}
abstract void setInput(ByteBuf compressed);
abstract void decode(ByteBuf decompressed) throws Exception;
abstract int decode(ByteBuf decompressed) throws Exception;
abstract void end();
}

View File

@ -43,7 +43,7 @@ class SpdyHeaderBlockZlibDecompressor extends SpdyHeaderBlockDecompressor {
}
@Override
public void decode(ByteBuf decompressed) throws Exception {
public int decode(ByteBuf decompressed) throws Exception {
try {
int numBytes = decompressor.inflate(out);
if (numBytes == 0 && decompressor.needsDictionary()) {
@ -55,6 +55,7 @@ class SpdyHeaderBlockZlibDecompressor extends SpdyHeaderBlockDecompressor {
numBytes = decompressor.inflate(out);
}
decompressed.writeBytes(out, 0, numBytes);
return numBytes;
} catch (DataFormatException e) {
throw new SpdyProtocolException(
"Received invalid header block", e);