secur32: Fix wrapper.c to honour functions that are run twice.

Kai Blin blin at gmx.net
Sun Aug 21 13:15:55 CDT 2005


Fixed the wrapper calls to InitializeSecurityContext(A/W) and
AcceptSecurityContext to correctly handle SEC_I_CONTINUE_NEEDED returns.

Corrected writing the wrapped context to the correct variable.

Corrected InitializeSecurityContext(A/W)'s and AcceptSecurityContext's
calls to unwrap the context before passing it to the package's
functions.

Changelog:
Kai Blin <blin at gmx.net>
Fixed a couple of bugs in InitializeSecurityContext(A/W) and 
AcceptSecurityContext.

-- 
Kai Blin, (blin at gmx dot net)
How sharper than a hound's tooth it is to have a thankless serpent.
-------------- next part --------------
Index: dlls/secur32/wrapper.c
===================================================================
RCS file: /home/wine/wine/dlls/secur32/wrapper.c,v
retrieving revision 1.2
diff -u -3 -r1.2 wrapper.c
--- dlls/secur32/wrapper.c	17 May 2004 21:08:31 -0000	1.2
+++ dlls/secur32/wrapper.c	21 Aug 2005 18:13:33 -0000
@@ -35,6 +35,7 @@
 static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
  SecurePackage *package, PSecHandle realHandle)
 {
+    TRACE("%p %p %p\n", phSec, package, realHandle);
     SECURITY_STATUS ret;
 
     if (phSec && package && realHandle)
@@ -260,13 +261,20 @@
             {
                 CtxtHandle myCtxt;
 
+                if(phContext)
+                {
+                    PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
+                    myCtxt.dwUpper = realCtxt->dwUpper;
+                    myCtxt.dwLower = realCtxt->dwLower;
+                }
+
                 ret = package->provider->fnTableA.InitializeSecurityContextA(
                  cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq,
                  Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt,
                  pOutput, pfContextAttr, ptsExpiry);
-                if (ret == SEC_E_OK)
+                if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
                 {
-                    ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
+                    ret = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
                     if (ret != SEC_E_OK)
                         package->provider->fnTableW.DeleteSecurityContext(
                          &myCtxt);
@@ -309,13 +317,20 @@
             {
                 CtxtHandle myCtxt;
 
+                if(phContext)
+                {
+                    PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
+                    myCtxt.dwUpper = realCtxt->dwUpper;
+                    myCtxt.dwLower = realCtxt->dwLower;
+                }
+
                 ret = package->provider->fnTableW.InitializeSecurityContextW(
                  cred, phContext ? &myCtxt : NULL, pszTargetName, fContextReq,
                  Reserved1, TargetDataRep, pInput, Reserved2, &myCtxt,
                  pOutput, pfContextAttr, ptsExpiry);
-                if (ret == SEC_E_OK)
+                if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
                 {
-                    ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
+                    ret = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
                     if (ret != SEC_E_OK)
                         package->provider->fnTableW.DeleteSecurityContext(
                          &myCtxt);
@@ -357,12 +372,20 @@
             {
                 CtxtHandle myCtxt;
 
+                if(phContext)
+                {
+                    PCtxtHandle realCtxt = (PCtxtHandle)phContext->dwLower;
+                    TRACE("realCtx: %p\n", realCtxt);
+                    myCtxt.dwUpper = realCtxt->dwUpper;
+                    myCtxt.dwLower = realCtxt->dwLower;
+                }
+                
                 ret = package->provider->fnTableW.AcceptSecurityContext(
                  cred, phContext ? &myCtxt : NULL, pInput, fContextReq,
                  TargetDataRep, &myCtxt, pOutput, pfContextAttr, ptsExpiry);
-                if (ret == SEC_E_OK)
+                if (ret == SEC_E_OK || ret == SEC_I_CONTINUE_NEEDED)
                 {
-                    ret = SECUR32_makeSecHandle(phContext, package, &myCtxt);
+                    ret = SECUR32_makeSecHandle(phNewContext, package, &myCtxt);
                     if (ret != SEC_E_OK)
                         package->provider->fnTableW.DeleteSecurityContext(
                          &myCtxt);


More information about the wine-patches mailing list