From b9f1f5a17cc60d5f690fdda236208a7ed7207d64 Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Wed, 6 Dec 2017 21:54:45 +0800 Subject: [PATCH] HBASE-18112 (addendum) fix the out-of-bounds index --- .../org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java index d6007128579..1b395a4ccee 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcFrameDecoder.java @@ -95,18 +95,14 @@ public class NettyRpcFrameDecoder extends ByteToMessageDecoder { } int frameLengthInt = (int) frameLength; - if (in.readableBytes() < frameLengthInt) { + if (in.readableBytes() < frameLengthInt + FRAME_LENGTH_FIELD_LENGTH) { return; } in.skipBytes(FRAME_LENGTH_FIELD_LENGTH); // extract frame - int readerIndex = in.readerIndex(); - ByteBuf frame = in.retainedSlice(readerIndex, frameLengthInt); - in.readerIndex(readerIndex + frameLengthInt); - - out.add(frame); + out.add(in.readRetainedSlice(frameLengthInt)); } private void handleTooBigRequest(ByteBuf in) throws IOException {