Merge pull request #755 from jaens/3-spdy-fix-truncation-2
SPDY: fix header block values truncation in decompression
This commit is contained in:
commit
6f589dd12b
@ -544,8 +544,13 @@ public class SpdyFrameDecoder extends FrameDecoder {
|
||||
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() {
|
||||
|
@ -24,6 +24,6 @@ abstract class SpdyHeaderBlockDecompressor {
|
||||
}
|
||||
|
||||
abstract void setInput(ChannelBuffer compressed);
|
||||
abstract void decode(ChannelBuffer decompressed) throws Exception;
|
||||
abstract int decode(ChannelBuffer decompressed) throws Exception;
|
||||
abstract void end();
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class SpdyHeaderBlockZlibDecompressor extends SpdyHeaderBlockDecompressor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ChannelBuffer decompressed) throws Exception {
|
||||
public int decode(ChannelBuffer decompressed) throws Exception {
|
||||
try {
|
||||
int numBytes = decompressor.inflate(out);
|
||||
if (numBytes == 0 && decompressor.needsDictionary()) {
|
||||
@ -56,6 +56,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);
|
||||
|
Loading…
Reference in New Issue
Block a user