Merge pull request #10793 from akallabeth/ntlm-fixes
[winpr,sspi] fix NULL NTLM password handling
This commit is contained in:
commit
fa71cb18f0
@ -336,10 +336,13 @@ static BOOL copy(WCHAR** dst, ULONG* dstLen, const WCHAR* what, size_t len)
|
||||
/* Case what="" and len=0 should allocate an empty string */
|
||||
if (!what && (len != 0))
|
||||
return FALSE;
|
||||
if (!what && (len == 0))
|
||||
return TRUE;
|
||||
|
||||
*dst = calloc(sizeof(WCHAR), len + 1);
|
||||
if (!*dst)
|
||||
return FALSE;
|
||||
if (what)
|
||||
|
||||
memcpy(*dst, what, len * sizeof(WCHAR));
|
||||
*dstLen = len;
|
||||
return TRUE;
|
||||
@ -380,9 +383,18 @@ int sspi_SetAuthIdentityA(SEC_WINNT_AUTH_IDENTITY* identity, const char* user, c
|
||||
size_t unicodeUserLenW = 0;
|
||||
size_t unicodeDomainLenW = 0;
|
||||
size_t unicodePasswordLenW = 0;
|
||||
LPWSTR unicodeUser = ConvertUtf8ToWCharAlloc(user, &unicodeUserLenW);
|
||||
LPWSTR unicodeDomain = ConvertUtf8ToWCharAlloc(domain, &unicodeDomainLenW);
|
||||
LPWSTR unicodePassword = ConvertUtf8ToWCharAlloc(password, &unicodePasswordLenW);
|
||||
LPWSTR unicodeUser = NULL;
|
||||
LPWSTR unicodeDomain = NULL;
|
||||
LPWSTR unicodePassword = NULL;
|
||||
|
||||
if (user)
|
||||
unicodeUser = ConvertUtf8ToWCharAlloc(user, &unicodeUserLenW);
|
||||
|
||||
if (domain)
|
||||
unicodeDomain = ConvertUtf8ToWCharAlloc(domain, &unicodeDomainLenW);
|
||||
|
||||
if (password)
|
||||
unicodePassword = ConvertUtf8ToWCharAlloc(password, &unicodePasswordLenW);
|
||||
|
||||
rc = sspi_SetAuthIdentityWithLengthW(identity, unicodeUser, unicodeUserLenW, unicodeDomain,
|
||||
unicodeDomainLenW, unicodePassword, unicodePasswordLenW);
|
||||
|
@ -780,7 +780,7 @@ int TestNTLM(int argc, char* argv[])
|
||||
{ TEST_NTLM_USER, TEST_NTLM_DOMAIN, "", TEST_EMPTY_PWD_NTLM_HASH,
|
||||
TEST_EMPTY_PWD_NTLM_V2_HASH, TRUE, TRUE },
|
||||
{ TEST_NTLM_USER, TEST_NTLM_DOMAIN, NULL, TEST_EMPTY_PWD_NTLM_HASH,
|
||||
TEST_EMPTY_PWD_NTLM_V2_HASH, TRUE, TRUE }
|
||||
TEST_EMPTY_PWD_NTLM_V2_HASH, TRUE, FALSE }
|
||||
};
|
||||
|
||||
int rc = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user