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.
This commit is contained in:
parent
5819b90f95
commit
fef5ce52ce
|
@ -1421,13 +1421,17 @@ RpcBindingSetAuthInfoExA( RPC_BINDING_HANDLE Binding, RPC_CSTR ServerPrincName,
|
||||||
FreeContextBuffer(packages);
|
FreeContextBuffer(packages);
|
||||||
if (r == ERROR_SUCCESS)
|
if (r == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
|
RpcAuthInfo *new_auth_info;
|
||||||
bind->AuthInfo = NULL;
|
|
||||||
r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken,
|
r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken,
|
||||||
AuthIdentity, &bind->AuthInfo);
|
AuthIdentity, &new_auth_info);
|
||||||
if (r != RPC_S_OK)
|
if (r == RPC_S_OK)
|
||||||
|
{
|
||||||
|
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
|
||||||
|
bind->AuthInfo = new_auth_info;
|
||||||
|
}
|
||||||
|
else
|
||||||
FreeCredentialsHandle(&cred);
|
FreeCredentialsHandle(&cred);
|
||||||
return RPC_S_OK;
|
return r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1537,13 +1541,17 @@ RpcBindingSetAuthInfoExW( RPC_BINDING_HANDLE Binding, RPC_WSTR ServerPrincName,
|
||||||
FreeContextBuffer(packages);
|
FreeContextBuffer(packages);
|
||||||
if (r == ERROR_SUCCESS)
|
if (r == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
|
RpcAuthInfo *new_auth_info;
|
||||||
bind->AuthInfo = NULL;
|
|
||||||
r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken,
|
r = RpcAuthInfo_Create(AuthnLevel, AuthnSvc, cred, exp, cbMaxToken,
|
||||||
AuthIdentity, &bind->AuthInfo);
|
AuthIdentity, &new_auth_info);
|
||||||
if (r != RPC_S_OK)
|
if (r == RPC_S_OK)
|
||||||
|
{
|
||||||
|
if (bind->AuthInfo) RpcAuthInfo_Release(bind->AuthInfo);
|
||||||
|
bind->AuthInfo = new_auth_info;
|
||||||
|
}
|
||||||
|
else
|
||||||
FreeCredentialsHandle(&cred);
|
FreeCredentialsHandle(&cred);
|
||||||
return RPC_S_OK;
|
return r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue