From 92d9a741c0c47d421ba0ad6f401fc2cccbd83032 Mon Sep 17 00:00:00 2001 From: Mate Barany Date: Mon, 2 Sep 2024 14:21:29 +0200 Subject: [PATCH] Use NSDMI for all the members of the QNtlmPhaseBlock classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the base and derived classes have been merged we can uniformize the initialization as well. Task-number: QTBUG-127539 Change-Id: I3828dc973fd7b3ccd06272e2e26eaae4edab8768 Reviewed-by: MÃ¥rten Nordheim (cherry picked from commit c3093b3d8f27fa3df14e04245dea9ed1e781f61e) Reviewed-by: Qt Cherry-pick Bot --- src/network/kernel/qauthenticator.cpp | 33 +++++++-------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index cb7e0e0b4cf..02a12f1dff7 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -1068,18 +1068,12 @@ static QDataStream& operator>>(QDataStream& s, QNtlmBuffer& b) class QNtlmPhase1Block { // request public: - char magic[8]; - quint32 type; - quint32 flags; + char magic[8] = {'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0'}; + quint32 type = 1; + quint32 flags = NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_ALWAYS_SIGN | NTLMSSP_NEGOTIATE_NTLM2; QNtlmBuffer domain; QNtlmBuffer workstation; - QNtlmPhase1Block() { - qstrncpy(magic, "NTLMSSP", 8); - type = 1; - flags = NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_ALWAYS_SIGN | NTLMSSP_NEGOTIATE_NTLM2; - } - // extracted QString domainStr, workstationStr; }; @@ -1088,8 +1082,8 @@ public: class QNtlmPhase2Block { // challenge public: - char magic[8]; - quint32 type; + char magic[8] = {0}; + quint32 type = 0xffffffff; QNtlmBuffer targetName; quint32 flags = 0; unsigned char challenge[8] = {'\0'}; @@ -1097,11 +1091,6 @@ public: QNtlmBuffer targetInfo; enum { Size = 48 }; - QNtlmPhase2Block() { - magic[0] = 0; - type = 0xffffffff; - } - // extracted QString targetNameStr, targetInfoStr; QByteArray targetInfoBuff; @@ -1112,23 +1101,17 @@ public: class QNtlmPhase3Block { // response public: - char magic[8]; - quint32 type; + char magic[8] = {'N', 'T', 'L', 'M', 'S', 'S', 'P', '\0'}; + quint32 type = 3; QNtlmBuffer lmResponse; QNtlmBuffer ntlmResponse; QNtlmBuffer domain; QNtlmBuffer user; QNtlmBuffer workstation; QNtlmBuffer sessionKey; - quint32 flags; + quint32 flags = NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO; enum { Size = 64 }; - QNtlmPhase3Block() { - qstrncpy(magic, "NTLMSSP", 8); - type = 3; - flags = NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_TARGET_INFO; - } - // extracted QByteArray lmResponseBuf, ntlmResponseBuf; QString domainStr, userStr, workstationStr, sessionKeyStr;