From fb46006c0aa2f5829fa80cf1cfbaa57900ff202b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 12 Jul 2020 15:25:35 +0300 Subject: more correct implementation of TNtlmAuth --- protocols/JabberG/src/jabber_secur.cpp | 17 +++++++++-------- protocols/JabberG/src/jabber_secur.h | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp index c92cc4dc64..a4f21a7d77 100644 --- a/protocols/JabberG/src/jabber_secur.cpp +++ b/protocols/JabberG/src/jabber_secur.cpp @@ -51,6 +51,14 @@ TNtlmAuth::TNtlmAuth(ThreadData *info, const char *mechanism) : if ((hProvider = Netlib_InitSecurityProvider(szProvider, szSpn)) == nullptr) return; + // This generates login method advertisement packet + if (info->conn.password[0] != 0) + szInitRequest = Netlib_NtlmCreateResponse(hProvider, "", Utf2T(info->conn.username), Utf2T(info->conn.password), complete); + else + szInitRequest = Netlib_NtlmCreateResponse(hProvider, "", nullptr, nullptr, complete); + if (szInitRequest == nullptr) + return; + bIsValid = true; } @@ -98,14 +106,7 @@ bool TNtlmAuth::getSpn(wchar_t* szSpn, size_t dwSpnLen) char* TNtlmAuth::getInitialRequest() { - if (!hProvider) - return nullptr; - - // This generates login method advertisement packet - if (info->conn.password[0] != 0) - return Netlib_NtlmCreateResponse(hProvider, "", Utf2T(info->conn.username), Utf2T(info->conn.password), complete); - - return Netlib_NtlmCreateResponse(hProvider, "", nullptr, nullptr, complete); + return szInitRequest.detach(); } char* TNtlmAuth::getChallenge(const char *challenge) diff --git a/protocols/JabberG/src/jabber_secur.h b/protocols/JabberG/src/jabber_secur.h index 14ad699b70..26286b491b 100644 --- a/protocols/JabberG/src/jabber_secur.h +++ b/protocols/JabberG/src/jabber_secur.h @@ -110,6 +110,7 @@ class TNtlmAuth : public TJabberAuth typedef TJabberAuth CSuper; HANDLE hProvider; + ptrA szInitRequest; public: TNtlmAuth(ThreadData*, const char* mechanism); -- cgit v1.2.3