From fef5ce52ce380c17de68ef1cd7df063e364f2846 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Wed, 23 Jan 2008 16:32:45 +0000 Subject: [PATCH] rpcrt4: Fix the error handling in RpcBindingSetAuthInfoA/W when RpcAuthInfo_Create fails. Don't release the old auth info until we successfully have a new auth info and return failure to the caller if RpcAuthInfo_Create fails. --- dlls/rpcrt4/rpc_binding.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/dlls/rpcrt4/rpc_binding.c b/dlls/rpcrt4/rpc_binding.c index 24769e2ce6..bcf89da25f 100644 --- a/dlls/rpcrt4/rpc_binding.c +++ b/dlls/rpcrt4/rpc_binding.c @@ -1421,13 +1421,17 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName, FreeContextBuffer(packages); if (r == ERROR_SUCCESS) { - if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo); - bind->AuthInfo = NULL; + RpcAuthInfo *new_auth_info; r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken, - AuthIdentity, &bind->AuthInfo); - if (r != RPC_S_OK) + AuthIdentity, &new_auth_info); + if (r == RPC_S_OK) + { + if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo); + bind->AuthInfo = new_auth_info; + } + else FreeCredentialsHandle(&cred); - return RPC_S_OK; + return r; } else { @@ -1537,13 +1541,17 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName, FreeContextBuffer(packages); if (r == ERROR_SUCCESS) { - if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo); - bind->AuthInfo = NULL; + RpcAuthInfo *new_auth_info; r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken, - AuthIdentity, &bind->AuthInfo); - if (r != RPC_S_OK) + AuthIdentity, &new_auth_info); + if (r == RPC_S_OK) + { + if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo); + bind->AuthInfo = new_auth_info; + } + else FreeCredentialsHandle(&cred); - return RPC_S_OK; + return r; } else { -- 2.32.0.93.g670b81a890