secur32: NTLM's AcquireCredentialHandleA/W should accept domains and usernames with lengths of 0.

Add tests for these cases.
This commit is contained in:
Rob Shearman 2007-03-06 13:32:09 +00:00 committed by Alexandre Julliard
parent d9229bd1c5
commit b814c45f00
2 changed files with 69 additions and 6 deletions

View File

@ -163,12 +163,6 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(
PSEC_WINNT_AUTH_IDENTITY_W auth_data =
(PSEC_WINNT_AUTH_IDENTITY_W)pAuthData;
if (!auth_data->UserLength || !auth_data->DomainLength)
{
ret = SEC_E_NO_CREDENTIALS;
phCredential = NULL;
break;
}
/* Get username and domain from pAuthData */
username = HeapAlloc(GetProcessHeap(), 0,
(auth_data->UserLength + 1) * sizeof(SEC_WCHAR));

View File

@ -1116,6 +1116,74 @@ end:
HeapFree(GetProcessHeap(), 0, complex_data[3].pvBuffer);
}
static void testAcquireCredentialsHandle(void)
{
CredHandle cred;
TimeStamp ttl;
static char test_user[] = "testuser",
workgroup[] = "WORKGROUP",
test_pass[] = "testpass",
sec_pkg_name[] = "NTLM";
SECURITY_STATUS ret;
SEC_WINNT_AUTH_IDENTITY id;
PSecPkgInfo pkg_info = NULL;
if(pQuerySecurityPackageInfoA(sec_pkg_name, &pkg_info) != SEC_E_OK)
{
skip("NTLM package not installed, skipping test\n");
return;
}
pFreeContextBuffer(pkg_info);
id.User = (unsigned char*) test_user;
id.UserLength = strlen((char *) id.User);
id.Domain = (unsigned char *) workgroup;
id.DomainLength = strlen((char *) id.Domain);
id.Password = (unsigned char*) test_pass;
id.PasswordLength = strlen((char *) id.Password);
id.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
id.DomainLength = 0;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
id.Domain = NULL;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
id.Domain = (unsigned char *) workgroup;
id.DomainLength = strlen((char *) id.Domain);
id.UserLength = 0;
id.User = NULL;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
id.User = (unsigned char*) test_user;
id.UserLength = strlen((char *) id.User);
id.Password = NULL;
id.PasswordLength = 0;
ret = pAcquireCredentialsHandleA(NULL, sec_pkg_name, SECPKG_CRED_OUTBOUND,
NULL, &id, NULL, NULL, &cred, &ttl);
ok(ret == SEC_E_OK, "AcquireCredentialsHande() returned %s\n",
getSecError(ret));
pFreeCredentialsHandle(&cred);
}
START_TEST(ntlm)
{
InitFunctionPtrs();
@ -1125,6 +1193,7 @@ START_TEST(ntlm)
pInitializeSecurityContextA && pCompleteAuthToken &&
pQuerySecurityPackageInfoA)
{
testAcquireCredentialsHandle();
testInitializeSecurityContextFlags();
if(pAcceptSecurityContext)
{