Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISPN-6545 Avoid leaking HR server req details #4266

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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() {
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may as well remove this method while we are at it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

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
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ class CacheDecodeContext(server: HotRodServer) extends ServerConstants with Log
var getAllSet: Set[Bytes] = _
var operationDecodeContext: Any = _

def resetParams(): Unit = {
decoder = null
header = null
params = null
key = null
rawValue = null
putAllMap = null
getAllSet = null
operationDecodeContext = null
}

def createExceptionResponse(e: Throwable): (ErrorResponse) = {
e match {
case i: InvalidMagicIdException =>
Expand Down