From 29d3b0bebb399bf1db24c48ba8186a79d4000643 Mon Sep 17 00:00:00 2001 From: Konrad Witaszczyk Date: Mon, 18 May 2015 09:42:17 +0200 Subject: [PATCH] QueryContextAttributes shouldn't return an error when a user or a domain is empty. --- winpr/libwinpr/sspi/NTLM/ntlm.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c index cdd9fdc8d..b6f7085a6 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm.c @@ -671,21 +671,27 @@ SECURITY_STATUS SEC_ENTRY ntlm_QueryContextAttributesW(PCtxtHandle phContext, UL context->UseSamFileDatabase = FALSE; credentials = context->credentials; ZeroMemory(AuthIdentity, sizeof(SecPkgContext_AuthIdentity)); - UserA = AuthIdentity->User; - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) credentials->identity.User, - credentials->identity.UserLength, - &UserA, 256, NULL, NULL); - if (status <= 0) - return SEC_E_INTERNAL_ERROR; + UserA = AuthIdentity->User; + if (credentials->identity.UserLength > 0) { + status = ConvertFromUnicode(CP_UTF8, 0, + (WCHAR *)credentials->identity.User, + credentials->identity.UserLength, &UserA, 256, NULL, + NULL); + if (status <= 0) + return SEC_E_INTERNAL_ERROR; + } DomainA = AuthIdentity->Domain; - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) credentials->identity.Domain, - credentials->identity.DomainLength, - &DomainA, 256, NULL, NULL); + if (credentials->identity.DomainLength > 0) { + status = ConvertFromUnicode(CP_UTF8, 0, + (WCHAR *)credentials->identity.Domain, + credentials->identity.DomainLength, &DomainA, 256, + NULL, NULL); - if (status <= 0) - return SEC_E_INTERNAL_ERROR; + if (status <= 0) + return SEC_E_INTERNAL_ERROR; + } return SEC_E_OK; }