Schannel: chop off garbage bytes if encryption fails
Because they would break communication (or loop infinitely) otherwise since we use the presence of bytes in the returned buffer to know if there is still something we need to transmit. Amends 4e60a6b556d91ab797aebb7422666a685a726755 Change-Id: If72c1a142d4567f69d78177250b0218c5ca999fd Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit 1efcc0df6adab11e7239f5f12a13766a58e2c1ea) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5fa520a77c
commit
ab667d881d
@ -1788,7 +1788,7 @@ auto TlsCryptographSchannel::getNextEncryptedMessage() -> MessageBufferResult
|
||||
&& fullMessage.size() < MessageBufferThreshold) {
|
||||
// Try to read 'cbMaximumMessage' bytes from buffer before encrypting.
|
||||
const int bodySize = int(std::min(writeBufferSize, qint64(streamSizes.cbMaximumMessage)));
|
||||
auto messageSize = headerSize + bodySize + trailerSize;
|
||||
const qsizetype messageSize = headerSize + bodySize + trailerSize;
|
||||
QSpan buffer = allocateMessage(messageSize);
|
||||
char *header = buffer.data();
|
||||
char *body = header + headerSize;
|
||||
@ -1815,6 +1815,7 @@ auto TlsCryptographSchannel::getNextEncryptedMessage() -> MessageBufferResult
|
||||
setErrorAndEmit(d, QAbstractSocket::SslInternalError,
|
||||
QSslSocket::tr("Schannel failed to encrypt data: %1")
|
||||
.arg(schannelErrorToString(status)));
|
||||
result.messageBuffer.chop(messageSize);
|
||||
return result;
|
||||
}
|
||||
// Data was encrypted successfully, so we free() what we peek()ed earlier
|
||||
|
Loading…
x
Reference in New Issue
Block a user