Commit ee47c5a2 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

secur32: Fix the wrapper InitializeSecurityContextA/W functions to handle…

secur32: Fix the wrapper InitializeSecurityContextA/W functions to handle phContext and phNewContext parameters being optional for some SSPs.
parent e24667cc
...@@ -247,14 +247,24 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA( ...@@ -247,14 +247,24 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA(
ULONG *pfContextAttr, PTimeStamp ptsExpiry) ULONG *pfContextAttr, PTimeStamp ptsExpiry)
{ {
SECURITY_STATUS ret; SECURITY_STATUS ret;
SecurePackage *package = NULL;
PCredHandle cred = NULL;
PCredHandle ctxt = NULL;
TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext, TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput, debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry); Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
if (phContext)
{
package = (SecurePackage *)phContext->dwUpper;
ctxt = (PCtxtHandle)phContext->dwLower;
}
if (phCredential) if (phCredential)
{ {
SecurePackage *package = (SecurePackage *)phCredential->dwUpper; package = (SecurePackage *)phCredential->dwUpper;
PCredHandle cred = (PCredHandle)phCredential->dwLower; cred = (PCredHandle)phCredential->dwLower;
}
if (package && package->provider) if (package && package->provider)
{ {
...@@ -262,7 +272,7 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA( ...@@ -262,7 +272,7 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA(
{ {
CtxtHandle myCtxt; CtxtHandle myCtxt;
if(phContext) if (phContext)
{ {
PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower; PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
myCtxt.dwUpper = realCtxt->dwUpper; myCtxt.dwUpper = realCtxt->dwUpper;
...@@ -270,16 +280,15 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA( ...@@ -270,16 +280,15 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA(
} }
ret = package->provider->fnTableA.InitializeSecurityContextA( ret = package->provider->fnTableA.InitializeSecurityContextA(
cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq, cred, ctxt, pszTargetName, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt, Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
pOutput, pfContextAttr, ptsExpiry); pOutput, pfContextAttr, ptsExpiry);
if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) && phNewContext)
{ {
SECURITY_STATUS ret2; SECURITY_STATUS ret2;
ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt); ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
if (ret2 != SEC_E_OK) if (ret2 != SEC_E_OK)
package->provider->fnTableW.DeleteSecurityContext( package->provider->fnTableA.DeleteSecurityContext(&myCtxt);
&myCtxt);
} }
} }
else else
...@@ -287,9 +296,6 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA( ...@@ -287,9 +296,6 @@ SECURITY_STATUS WINAPI InitializeSecurityContextA(
} }
else else
ret = SEC_E_INVALID_HANDLE; ret = SEC_E_INVALID_HANDLE;
}
else
ret = SEC_E_INVALID_HANDLE;
return ret; return ret;
} }
...@@ -304,22 +310,32 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW( ...@@ -304,22 +310,32 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW(
ULONG *pfContextAttr, PTimeStamp ptsExpiry) ULONG *pfContextAttr, PTimeStamp ptsExpiry)
{ {
SECURITY_STATUS ret; SECURITY_STATUS ret;
SecurePackage *package = NULL;
PCredHandle cred = NULL;
PCredHandle ctxt = NULL;
TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext, TRACE("%p %p %s %d %d %d %p %d %p %p %p %p\n", phCredential, phContext,
debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput, debugstr_w(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry); Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
if (phContext)
{
package = (SecurePackage *)phContext->dwUpper;
ctxt = (PCtxtHandle)phContext->dwLower;
}
if (phCredential) if (phCredential)
{ {
SecurePackage *package = (SecurePackage *)phCredential->dwUpper; package = (SecurePackage *)phCredential->dwUpper;
PCredHandle cred = (PCredHandle)phCredential->dwLower; cred = (PCredHandle)phCredential->dwLower;
}
if (package && package->provider) if (package && package->provider)
{ {
if (package->provider->fnTableW.QueryCredentialsAttributesW) if (package->provider->fnTableW.InitializeSecurityContextW)
{ {
CtxtHandle myCtxt; CtxtHandle myCtxt;
if(phContext) if (phContext)
{ {
PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower; PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
myCtxt.dwUpper = realCtxt->dwUpper; myCtxt.dwUpper = realCtxt->dwUpper;
...@@ -327,16 +343,15 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW( ...@@ -327,16 +343,15 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW(
} }
ret = package->provider->fnTableW.InitializeSecurityContextW( ret = package->provider->fnTableW.InitializeSecurityContextW(
cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq, cred, ctxt, pszTargetName, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt, Reserved1, TargetDataRep, pInput, Reserved2, phNewContext ? &myCtxt : NULL,
pOutput, pfContextAttr, ptsExpiry); pOutput, pfContextAttr, ptsExpiry);
if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) if ((ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED) && phNewContext)
{ {
SECURITY_STATUS ret2; SECURITY_STATUS ret2;
ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt); ret2 = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
if (ret2 != SEC_E_OK) if (ret2 != SEC_E_OK)
package->provider->fnTableW.DeleteSecurityContext( package->provider->fnTableW.DeleteSecurityContext(&myCtxt);
&myCtxt);
} }
} }
else else
...@@ -344,9 +359,6 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW( ...@@ -344,9 +359,6 @@ SECURITY_STATUS WINAPI InitializeSecurityContextW(
} }
else else
ret = SEC_E_INVALID_HANDLE; ret = SEC_E_INVALID_HANDLE;
}
else
ret = SEC_E_INVALID_HANDLE;
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment