sspi/nla: implement ntlm_DeleteSecurityContext and start using ntlm_ContextFree to avoid leaking

This commit is contained in:
Mads Kiilerich 2012-03-16 18:12:49 +01:00
parent f787b8110e
commit 2692328878
3 changed files with 52 additions and 2 deletions

View File

@ -109,6 +109,22 @@ void ntlm_ContextFree(NTLM_CONTEXT* context)
if (!context)
return;
freerdp_uniconv_free(context->uniconv);
crypto_rc4_free(context->send_rc4_seal);
crypto_rc4_free(context->recv_rc4_seal);
sspi_SecBufferFree(&context->NegotiateMessage);
sspi_SecBufferFree(&context->ChallengeMessage);
sspi_SecBufferFree(&context->AuthenticateMessage);
sspi_SecBufferFree(&context->TargetInfo);
sspi_SecBufferFree(&context->TargetName);
sspi_SecBufferFree(&context->NtChallengeResponse);
sspi_SecBufferFree(&context->LmChallengeResponse);
xfree(context->identity.User);
xfree(context->identity.Password);
xfree(context->identity.Domain);
xfree(context->Workstation);
xfree(context->av_pairs->Timestamp.value);
xfree(context->av_pairs);
xfree(context);
}
@ -376,6 +392,20 @@ SECURITY_STATUS ntlm_InitializeSecurityContext(CredHandle* phCredential, CtxtHan
return SEC_E_OUT_OF_SEQUENCE;
}
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa375354 */
SECURITY_STATUS ntlm_DeleteSecurityContext(CtxtHandle* phContext)
{
NTLM_CONTEXT* context;
context = sspi_SecureHandleGetLowerPointer(phContext);
if (!context)
return SEC_E_INVALID_HANDLE;
ntlm_ContextFree(context);
return SEC_E_OK;
}
/* http://msdn.microsoft.com/en-us/library/windows/desktop/aa379337/ */
SECURITY_STATUS ntlm_QueryContextAttributes(CtxtHandle* phContext, uint32 ulAttribute, void* pBuffer)
@ -581,7 +611,7 @@ const SecurityFunctionTable NTLM_SecurityFunctionTable =
ntlm_InitializeSecurityContext, /* InitializeSecurityContext */
ntlm_AcceptSecurityContext, /* AcceptSecurityContext */
NULL, /* CompleteAuthToken */
NULL, /* DeleteSecurityContext */
ntlm_DeleteSecurityContext, /* DeleteSecurityContext */
NULL, /* ApplyControlToken */
ntlm_QueryContextAttributes, /* QueryContextAttributes */
ntlm_ImpersonateSecurityContext, /* ImpersonateSecurityContext */

View File

@ -1046,6 +1046,7 @@ void credssp_free(rdpCredssp* credssp)
{
if (credssp != NULL)
{
credssp->table->DeleteSecurityContext(&credssp->context);
sspi_SecBufferFree(&credssp->PublicKey);
sspi_SecBufferFree(&credssp->ts_credentials);
freerdp_uniconv_free(credssp->uniconv);

View File

@ -522,7 +522,26 @@ SECURITY_STATUS CompleteAuthToken(CtxtHandle* phContext, SecBufferDesc* pToken)
SECURITY_STATUS DeleteSecurityContext(CtxtHandle* phContext)
{
return SEC_E_OK;
char* Name;
SECURITY_STATUS status;
SecurityFunctionTable* table;
Name = (char*) sspi_SecureHandleGetUpperPointer(phContext);
if (!Name)
return SEC_E_SECPKG_NOT_FOUND;
table = sspi_GetSecurityFunctionTableByName(Name);
if (!table)
return SEC_E_SECPKG_NOT_FOUND;
if (table->DeleteSecurityContext == NULL)
return SEC_E_UNSUPPORTED_FUNCTION;
status = table->DeleteSecurityContext(phContext);
return status;
}
SECURITY_STATUS FreeContextBuffer(void* pvContextBuffer)