SslHandler.wrap(...) must ensure it not loose the original exception when finishWrap(...) fails (#9974)
Motivation: When SslHandler.finishWrap throws an exception, ensure that the promise and buf is not reused to avoid throwing IllegalArgumentException or IllegalReferenceCountException which causes the original exception to be lost. Modification: The change ensures that the values for the promise and bytebuf are nulled before calling finishWrap so that it will not be called again with the same arguments. Result: Fixes #9971 . Co-authored-by: Norman Maurer <norman_maurer@apple.com> Co-authored-by: Antony T Curtis <atcurtis@gmail.com>
This commit is contained in:
parent
b19958eda9
commit
a2bf0bfd7a
@ -860,11 +860,25 @@ public class SslHandler extends ByteToMessageDecoder {
|
||||
case NOT_HANDSHAKING:
|
||||
setHandshakeSuccessIfStillHandshaking();
|
||||
// deliberate fall-through
|
||||
case NEED_WRAP:
|
||||
finishWrap(ctx, out, promise, inUnwrap, false);
|
||||
case NEED_WRAP: {
|
||||
ChannelPromise p = promise;
|
||||
|
||||
// Null out the promise so it is not reused in the finally block in the cause of
|
||||
// finishWrap(...) throwing.
|
||||
promise = null;
|
||||
out = null;
|
||||
final ByteBuf b;
|
||||
|
||||
if (out.isReadable()) {
|
||||
// There is something in the out buffer. Ensure we null it out so it is not re-used.
|
||||
b = out;
|
||||
out = null;
|
||||
} else {
|
||||
// If out is not readable we can re-use it and so save an extra allocation
|
||||
b = null;
|
||||
}
|
||||
finishWrap(ctx, b, p, inUnwrap, false);
|
||||
break;
|
||||
}
|
||||
case NEED_UNWRAP:
|
||||
needUnwrap = true;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user