[#1878] Fix leak of ByteBuf when masked payload is used
This commit is contained in:
parent
328f67fdfe
commit
aaafdf909d
@ -91,7 +91,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
|||||||
private long framePayloadLength;
|
private long framePayloadLength;
|
||||||
private ByteBuf framePayload;
|
private ByteBuf framePayload;
|
||||||
private int framePayloadBytesRead;
|
private int framePayloadBytesRead;
|
||||||
private ByteBuf maskingKey;
|
private byte[] maskingKey;
|
||||||
private ByteBuf payloadBuffer;
|
private ByteBuf payloadBuffer;
|
||||||
|
|
||||||
private final boolean allowExtensions;
|
private final boolean allowExtensions;
|
||||||
@ -244,7 +244,10 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
|||||||
checkpoint(State.MASKING_KEY);
|
checkpoint(State.MASKING_KEY);
|
||||||
case MASKING_KEY:
|
case MASKING_KEY:
|
||||||
if (maskedPayload) {
|
if (maskedPayload) {
|
||||||
maskingKey = in.readBytes(4);
|
if (maskingKey == null) {
|
||||||
|
maskingKey = new byte[4];
|
||||||
|
}
|
||||||
|
in.readBytes(maskingKey);
|
||||||
}
|
}
|
||||||
checkpoint(State.PAYLOAD);
|
checkpoint(State.PAYLOAD);
|
||||||
case PAYLOAD:
|
case PAYLOAD:
|
||||||
@ -405,7 +408,7 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
|
|||||||
|
|
||||||
private void unmask(ByteBuf frame) {
|
private void unmask(ByteBuf frame) {
|
||||||
for (int i = frame.readerIndex(); i < frame.writerIndex(); i++) {
|
for (int i = frame.readerIndex(); i < frame.writerIndex(); i++) {
|
||||||
frame.setByte(i, frame.getByte(i) ^ maskingKey.getByte(i % 4));
|
frame.setByte(i, frame.getByte(i) ^ maskingKey[i % 4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user