Erasing memory on credentials or SecBuffer free.

This commit is contained in:
Armin Novak 2015-07-07 13:08:39 +02:00
parent 3b87cc0c07
commit 7360cb638a
1 changed files with 20 additions and 0 deletions

View File

@ -228,9 +228,28 @@ SSPI_CREDENTIALS* sspi_CredentialsNew()
void sspi_CredentialsFree(SSPI_CREDENTIALS* credentials)
{
size_t userLength;
size_t domainLength;
size_t passwordLength;
if (!credentials)
return;
userLength = credentials->identity.UserLength;
domainLength = credentials->identity.DomainLength;
passwordLength = credentials->identity.PasswordLength;
if (credentials->identity.Flags & SEC_WINNT_AUTH_IDENTITY_UNICODE)
{
userLength *= 2;
domainLength *= 2;
passwordLength *= 2;
}
memset(credentials->identity.User, 0, userLength);
memset(credentials->identity.Domain, 0, domainLength);
memset(credentials->identity.Password, 0, passwordLength);
free(credentials->identity.User);
free(credentials->identity.Domain);
free(credentials->identity.Password);
@ -256,6 +275,7 @@ void sspi_SecBufferFree(PSecBuffer SecBuffer)
if (!SecBuffer)
return;
memset(SecBuffer->pvBuffer, 0, SecBuffer->cbBuffer);
free(SecBuffer->pvBuffer);
SecBuffer->pvBuffer = NULL;
SecBuffer->cbBuffer = 0;