From 668ce80e9e0c37823312c4ebf3d11194a509f0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 23 Oct 2023 13:28:25 +0200 Subject: [PATCH] Schannel: change UNREACHABLE into error-handling Because it happens in some (unknown precondition) cases. While it would be nice to know what the client is doing to trigger this, it's not worth crashing over in the meantime. Fixes: QTBUG-118458 Pick-to: 6.6 6.5 6.2 Change-Id: I261a17578e7cd3a95e591a3228b33561000fd336 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov --- src/plugins/tls/schannel/qtls_schannel.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/tls/schannel/qtls_schannel.cpp b/src/plugins/tls/schannel/qtls_schannel.cpp index 98856288d4..d42aea42d0 100644 --- a/src/plugins/tls/schannel/qtls_schannel.cpp +++ b/src/plugins/tls/schannel/qtls_schannel.cpp @@ -1916,8 +1916,12 @@ void TlsCryptographSchannel::transmit() qCWarning(lcTlsBackendSchannel, "The internal SSPI handle is invalid!"); Q_UNREACHABLE(); } else if (status == SEC_E_INVALID_TOKEN) { - qCWarning(lcTlsBackendSchannel, "Got SEC_E_INVALID_TOKEN!"); - Q_UNREACHABLE(); // Happened once due to a bug, but shouldn't generally happen(?) + // Supposedly we have an invalid token, it's under-documented what + // this means, so to be safe we disconnect. + shutdown = true; + disconnectFromHost(); + setErrorAndEmit(d, QAbstractSocket::SslInternalError, schannelErrorToString(status)); + break; } else if (status == SEC_E_MESSAGE_ALTERED) { // The message has been altered, disconnect now. shutdown = true; // skips sending the shutdown alert