From da05dfd151153fda5731ddcdbcdb951354b5da56 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 30 Nov 2016 12:08:51 +0100 Subject: [PATCH] rpcrt4: Store security package name in rpc_server_registered_auth_info. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/rpcrt4/rpc_server.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c index 73e974289bc..c3bc2270cb2 100644 --- a/dlls/rpcrt4/rpc_server.c +++ b/dlls/rpcrt4/rpc_server.c @@ -1312,9 +1312,10 @@ struct rpc_server_registered_auth_info TimeStamp exp; BOOL cred_acquired; CredHandle cred; - ULONG max_token; USHORT auth_type; + WCHAR *package_name; WCHAR *principal; + ULONG max_token; }; static RPC_STATUS find_security_package(ULONG auth_type, SecPkgInfoW **packages_buf, SecPkgInfoW **ret) @@ -1361,17 +1362,11 @@ RPC_STATUS RPCRT4_ServerGetRegisteredAuthInfo( { if (!auth_info->cred_acquired) { - SecPkgInfoW *packages, *package; SECURITY_STATUS sec_status; - status = find_security_package(auth_info->auth_type, &packages, &package); - if (status != RPC_S_OK) - break; - - sec_status = AcquireCredentialsHandleW((SEC_WCHAR *)auth_info->principal, package->Name, + sec_status = AcquireCredentialsHandleW((SEC_WCHAR *)auth_info->principal, auth_info->package_name, SECPKG_CRED_INBOUND, NULL, NULL, NULL, NULL, &auth_info->cred, &auth_info->exp); - FreeContextBuffer(packages); if (sec_status != SEC_E_OK) { status = RPC_S_SEC_PKG_ERROR; @@ -1437,6 +1432,7 @@ RPC_STATUS WINAPI RpcServerRegisterAuthInfoW( RPC_WSTR ServerPrincName, ULONG Au { struct rpc_server_registered_auth_info *auth_info; SecPkgInfoW *packages, *package; + WCHAR *package_name; ULONG max_token; RPC_STATUS status; @@ -1446,20 +1442,27 @@ RPC_STATUS WINAPI RpcServerRegisterAuthInfoW( RPC_WSTR ServerPrincName, ULONG Au if (status != RPC_S_OK) return status; + package_name = RPCRT4_strdupW(package->Name); max_token = package->cbMaxToken; FreeContextBuffer(packages); - - auth_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*auth_info)); - if (!auth_info) + if (!package_name) return RPC_S_OUT_OF_RESOURCES; + auth_info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*auth_info)); + if (!auth_info) { + HeapFree(GetProcessHeap(), 0, package_name); + return RPC_S_OUT_OF_RESOURCES; + } + if (ServerPrincName && !(auth_info->principal = RPCRT4_strdupW(ServerPrincName))) { + HeapFree(GetProcessHeap(), 0, package_name); HeapFree(GetProcessHeap(), 0, auth_info); return RPC_S_OUT_OF_RESOURCES; } - auth_info->max_token = max_token; auth_info->auth_type = AuthnSvc; + auth_info->package_name = package_name; + auth_info->max_token = max_token; EnterCriticalSection(&server_auth_info_cs); list_add_tail(&server_registered_auth_info, &auth_info->entry);