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
fb3ced28cf
commit
663fbaa506
@ -858,11 +858,25 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
|||||||
case NOT_HANDSHAKING:
|
case NOT_HANDSHAKING:
|
||||||
setHandshakeSuccessIfStillHandshaking();
|
setHandshakeSuccessIfStillHandshaking();
|
||||||
// deliberate fall-through
|
// deliberate fall-through
|
||||||
case NEED_WRAP:
|
case NEED_WRAP: {
|
||||||
finishWrap(ctx, out, promise, inUnwrap, false);
|
ChannelPromise p = promise;
|
||||||
|
|
||||||
|
// Null out the promise so it is not reused in the finally block in the cause of
|
||||||
|
// finishWrap(...) throwing.
|
||||||
promise = null;
|
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;
|
break;
|
||||||
|
}
|
||||||
case NEED_UNWRAP:
|
case NEED_UNWRAP:
|
||||||
needUnwrap = true;
|
needUnwrap = true;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user