[#1879] Correctly validate close frame

This commit is contained in:
Norman Maurer 2013-10-01 07:32:07 +02:00
parent f70ceeab58
commit 7e6649fd66

View File

@ -443,10 +443,10 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
/** */
protected void checkCloseFrameBody(
ChannelHandlerContext ctx, ByteBuf buffer) {
if (buffer == null || buffer.capacity() == 0) {
if (buffer == null || !buffer.isReadable()) {
return;
}
if (buffer.capacity() == 1) {
if (buffer.readableBytes() == 1) {
protocolViolation(ctx, "Invalid close frame body");
}
@ -463,7 +463,6 @@ public class WebSocket08FrameDecoder extends ReplayingDecoder<WebSocket08FrameDe
// May have UTF-8 message
if (buffer.isReadable()) {
try {
new UTF8Output(buffer);
} catch (UTF8Exception ex) {