Skip to content

Commit

Permalink
ISPN-6545 Avoid leaking HR server req details
Browse files Browse the repository at this point in the history
  • Loading branch information
galderz committed Apr 25, 2016
1 parent e1d2525 commit f41439e
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public class HotRodDecoder extends ByteToMessageDecoder {
private final EmbeddedCacheManager cacheManager;
private final NettyTransport transport;
private final Predicate<? super String> ignoreCache;
private final HotRodServer server;

final CacheDecodeContext decodeCtx;
CacheDecodeContext decodeCtx;

private HotRodDecoderState state = HotRodDecoderState.DECODE_HEADER;

Expand All @@ -40,6 +41,7 @@ public HotRodDecoder(EmbeddedCacheManager cacheManager, NettyTransport transport
this.cacheManager = cacheManager;
this.transport = transport;
this.ignoreCache = ignoreCache;
this.server = server;

this.decodeCtx = new CacheDecodeContext(server);
}
Expand All @@ -49,7 +51,7 @@ public NettyTransport getTransport() {
}

void resetNow() {
decodeCtx.resetParams();
decodeCtx = new CacheDecodeContext(server);
decodeCtx.setHeader(new HotRodHeader());
state = HotRodDecoderState.DECODE_HEADER;
resetRequested = false;
Expand Down Expand Up @@ -117,16 +119,6 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
readCustomValue(in, out);
break;
}
int remainingBytes;
if (!out.isEmpty() && (remainingBytes = in.readableBytes()) > 0) {
// Clear out the request and wind bytes up to last so next caller isn't corrupted
out.clear();
in.readerIndex(in.writerIndex());
HotRodHeader header = decodeCtx.header();
throw new RequestParsingException("There are too many bytes for op " + header.op() +
" for version " + header.version() + " - had " + remainingBytes + " left over",
header.version(), header.messageId());
}
} catch (Throwable t) {
decodeCtx.setError(t);
resetRequested = true;
Expand Down

0 comments on commit f41439e

Please sign in to comment.