secur32: Use the global memory allocation helpers.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2018-02-14 14:13:09 +01:00 committed by Alexandre Julliard
parent 63b9fb3542
commit f0db56775e
11 changed files with 315 additions and 409 deletions

View File

@ -81,7 +81,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
fcntl( pipe_out[1], F_SETFD, FD_CLOEXEC );
}
if (!(helper = HeapAlloc(GetProcessHeap(),0, sizeof(NegoHelper))))
if (!(helper = heap_alloc( sizeof(NegoHelper) )))
{
close(pipe_in[0]);
close(pipe_in[1]);
@ -98,7 +98,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
close(pipe_in[1]);
close(pipe_out[0]);
close(pipe_out[1]);
HeapFree( GetProcessHeap(), 0, helper );
heap_free( helper );
return SEC_E_INTERNAL_ERROR;
}
@ -156,7 +156,7 @@ static SECURITY_STATUS read_line(PNegoHelper helper, int *offset_len)
if(helper->com_buf == NULL)
{
TRACE("Creating a new buffer for the helper\n");
if((helper->com_buf = HeapAlloc(GetProcessHeap(), 0, INITIAL_BUFFER_SIZE)) == NULL)
if (!(helper->com_buf = heap_alloc(INITIAL_BUFFER_SIZE)))
return SEC_E_INSUFFICIENT_MEMORY;
/* Created a new buffer, size is INITIAL_BUFFER_SIZE, offset is 0 */
@ -170,8 +170,7 @@ static SECURITY_STATUS read_line(PNegoHelper helper, int *offset_len)
if(helper->com_buf_offset + INITIAL_BUFFER_SIZE > helper->com_buf_size)
{
/* increment buffer size in INITIAL_BUFFER_SIZE steps */
char *buf = HeapReAlloc(GetProcessHeap(), 0, helper->com_buf,
helper->com_buf_size + INITIAL_BUFFER_SIZE);
char *buf = heap_realloc(helper->com_buf, helper->com_buf_size + INITIAL_BUFFER_SIZE);
TRACE("Resizing buffer!\n");
if (!buf) return SEC_E_INSUFFICIENT_MEMORY;
helper->com_buf_size += INITIAL_BUFFER_SIZE;
@ -280,8 +279,8 @@ void cleanup_helper(PNegoHelper helper)
if(helper == NULL)
return;
HeapFree(GetProcessHeap(), 0, helper->com_buf);
HeapFree(GetProcessHeap(), 0, helper->session_key);
heap_free(helper->com_buf);
heap_free(helper->session_key);
/* closing stdin will terminate ntlm_auth */
close(helper->pipe_out);
@ -297,7 +296,7 @@ void cleanup_helper(PNegoHelper helper)
}
#endif
HeapFree(GetProcessHeap(), 0, helper);
heap_free(helper);
}
void check_version(PNegoHelper helper)

View File

@ -94,7 +94,7 @@ NTSTATUS WINAPI LsaConnectUntrusted(PHANDLE LsaHandle)
TRACE("%p\n", LsaHandle);
lsa_conn = HeapAlloc(GetProcessHeap(), 0, sizeof(*lsa_conn));
lsa_conn = heap_alloc(sizeof(*lsa_conn));
if (!lsa_conn) return STATUS_NO_MEMORY;
lsa_conn->magic = LSA_MAGIC;
@ -122,7 +122,7 @@ NTSTATUS WINAPI LsaEnumerateLogonSessions(PULONG LogonSessionCount,
NTSTATUS WINAPI LsaFreeReturnBuffer(PVOID buffer)
{
TRACE("%p\n", buffer);
HeapFree(GetProcessHeap(), 0, buffer);
heap_free(buffer);
return STATUS_SUCCESS;
}
@ -186,26 +186,26 @@ static NTSTATUS NTAPI lsa_DeleteCredential(LUID *logon_id, ULONG package_id, LSA
static void * NTAPI lsa_AllocateLsaHeap(ULONG size)
{
TRACE("%u\n", size);
return HeapAlloc(GetProcessHeap(), 0, size);
return heap_alloc(size);
}
static void NTAPI lsa_FreeLsaHeap(void *p)
{
TRACE("%p\n", p);
HeapFree(GetProcessHeap(), 0, p);
heap_free(p);
}
static NTSTATUS NTAPI lsa_AllocateClientBuffer(PLSA_CLIENT_REQUEST req, ULONG size, void **p)
{
TRACE("%p,%u,%p\n", req, size, p);
*p = HeapAlloc(GetProcessHeap(), 0, size);
*p = heap_alloc(size);
return *p ? STATUS_SUCCESS : STATUS_NO_MEMORY;
}
static NTSTATUS NTAPI lsa_FreeClientBuffer(PLSA_CLIENT_REQUEST req, void *p)
{
TRACE("%p,%p\n", req, p);
HeapFree(GetProcessHeap(), 0, p);
heap_free(p);
return STATUS_SUCCESS;
}
@ -328,13 +328,13 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (principal)
{
int len = MultiByteToWideChar( CP_ACP, 0, principal, -1, NULL, 0 );
if (!(principalW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(SEC_WCHAR) ))) goto done;
if (!(principalW = heap_alloc( len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, principal, -1, principalW, len );
}
if (package)
{
int len = MultiByteToWideChar( CP_ACP, 0, package, -1, NULL, 0 );
if (!(packageW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(SEC_WCHAR) ))) goto done;
if (!(packageW = heap_alloc( len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, package, -1, packageW, len );
}
if (auth_data)
@ -343,23 +343,23 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (id->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
if (!(auth_dataW = HeapAlloc( GetProcessHeap(), 0, sizeof(SEC_WINNT_AUTH_IDENTITY_W) ))) goto done;
if (!(auth_dataW = heap_alloc( sizeof(SEC_WINNT_AUTH_IDENTITY_W) ))) goto done;
if (id->UserLength)
{
len_user = MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, NULL, 0 );
if (!(user = HeapAlloc( GetProcessHeap(), 0, len_user * sizeof(SEC_WCHAR) ))) goto done;
if (!(user = heap_alloc( len_user * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, user, len_user );
}
if (id->DomainLength)
{
len_domain = MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, NULL, 0 );
if (!(domain = HeapAlloc( GetProcessHeap(), 0, len_domain * sizeof(SEC_WCHAR) ))) goto done;
if (!(domain = heap_alloc( len_domain * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, domain, len_domain );
}
if (id->PasswordLength)
{
len_passwd = MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, NULL, 0 );
if (!(passwd = HeapAlloc( GetProcessHeap(), 0, len_passwd * sizeof(SEC_WCHAR) ))) goto done;
if (!(passwd = heap_alloc( len_passwd * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, passwd, len_passwd );
}
auth_dataW->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
@ -376,12 +376,12 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
status = lsa_AcquireCredentialsHandleW( principalW, packageW, credentials_use, logon_id, auth_dataW, get_key_fn,
get_key_arg, credential, ts_expiry );
done:
if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) HeapFree( GetProcessHeap(), 0, auth_dataW );
HeapFree( GetProcessHeap(), 0, packageW );
HeapFree( GetProcessHeap(), 0, principalW );
HeapFree( GetProcessHeap(), 0, user );
HeapFree( GetProcessHeap(), 0, domain );
HeapFree( GetProcessHeap(), 0, passwd );
if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) heap_free( auth_dataW );
heap_free( packageW );
heap_free( principalW );
heap_free( user );
heap_free( domain );
heap_free( passwd );
return status;
}
@ -464,13 +464,13 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
if (target_name)
{
int len = MultiByteToWideChar( CP_ACP, 0, target_name, -1, NULL, 0 );
if (!(targetW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
if (!(targetW = heap_alloc( len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, target_name, -1, targetW, len );
}
status = lsa_InitializeSecurityContextW( credential, context, targetW, context_req, reserved1, target_data_rep,
input, reserved2, new_context, output, context_attr, ts_expiry );
HeapFree( GetProcessHeap(), 0, targetW );
heap_free( targetW );
return status;
}
@ -560,7 +560,7 @@ static SecPkgInfoA *package_infoWtoA( const SecPkgInfoW *info )
int size_name = WideCharToMultiByte( CP_ACP, 0, info->Name, -1, NULL, 0, NULL, NULL );
int size_comment = WideCharToMultiByte( CP_ACP, 0, info->Comment, -1, NULL, 0, NULL, NULL );
if (!(ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) + size_name + size_comment ))) return NULL;
if (!(ret = heap_alloc( sizeof(*ret) + size_name + size_comment ))) return NULL;
ret->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID;
@ -778,9 +778,9 @@ static void add_package(struct lsa_package *package)
struct lsa_package *new_loaded_packages;
if (!loaded_packages)
new_loaded_packages = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_loaded_packages));
new_loaded_packages = heap_alloc(sizeof(*new_loaded_packages));
else
new_loaded_packages = HeapReAlloc(GetProcessHeap(), 0, loaded_packages, sizeof(*new_loaded_packages) * (loaded_packages_count + 1));
new_loaded_packages = heap_realloc(loaded_packages, sizeof(*new_loaded_packages) * (loaded_packages_count + 1));
if (new_loaded_packages)
{
@ -884,7 +884,7 @@ void load_auth_packages(void)
{
SecPkgInfoW *info;
info = HeapAlloc(GetProcessHeap(), 0, loaded_packages[i].lsa_table_count * sizeof(*info));
info = heap_alloc(loaded_packages[i].lsa_table_count * sizeof(*info));
if (info)
{
NTSTATUS status;
@ -893,7 +893,7 @@ void load_auth_packages(void)
if (status == STATUS_SUCCESS)
SECUR32_addPackages(provider, loaded_packages[i].lsa_table_count, NULL, info);
HeapFree(GetProcessHeap(), 0, info);
heap_free(info);
}
}
}

View File

@ -77,7 +77,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
if (!pszPackage) return SEC_E_SECPKG_NOT_FOUND;
if (!(cred = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cred) ))) return SEC_E_INSUFFICIENT_MEMORY;
if (!(cred = heap_alloc_zero( sizeof(*cred) ))) return SEC_E_INSUFFICIENT_MEMORY;
if ((package = SECUR32_findPackageW( kerberosW )))
{
@ -105,7 +105,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
return SEC_E_OK;
}
HeapFree( GetProcessHeap(), 0, cred );
heap_free( cred );
return ret;
}
@ -128,8 +128,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (pszPackage)
{
int package_len = MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, NULL, 0 );
package = HeapAlloc( GetProcessHeap(), 0, package_len * sizeof(SEC_WCHAR) );
if (!package) return SEC_E_INSUFFICIENT_MEMORY;
if (!(package = heap_alloc( package_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, package, package_len );
}
if (pAuthData)
@ -139,16 +138,14 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
identityW = HeapAlloc( GetProcessHeap(), 0, sizeof(*identityW) );
if (!identityW) goto done;
if (!(identityW = heap_alloc( sizeof(*identityW) ))) goto done;
if (!identity->UserLength) user_len = 0;
else
{
user_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User,
identity->UserLength, NULL, 0 );
user = HeapAlloc( GetProcessHeap(), 0, user_len * sizeof(SEC_WCHAR) );
if (!user) goto done;
if (!(user = heap_alloc( user_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User, identity->UserLength,
user, user_len );
}
@ -157,8 +154,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
domain_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain,
identity->DomainLength, NULL, 0 );
domain = HeapAlloc( GetProcessHeap(), 0, domain_len * sizeof(SEC_WCHAR) );
if (!domain) goto done;
if (!(domain = heap_alloc( domain_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain, identity->DomainLength,
domain, domain_len );
}
@ -167,8 +163,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{
passwd_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password,
identity->PasswordLength, NULL, 0 );
passwd = HeapAlloc( GetProcessHeap(), 0, passwd_len * sizeof(SEC_WCHAR) );
if (!passwd) goto done;
if (!(passwd = heap_alloc( passwd_len * sizeof(SEC_WCHAR) ))) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password, identity->PasswordLength,
passwd, passwd_len );
}
@ -185,11 +180,11 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
ret = nego_AcquireCredentialsHandleW( NULL, package, fCredentialUse, pLogonID, identityW,
pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry );
done:
HeapFree( GetProcessHeap(), 0, package );
HeapFree( GetProcessHeap(), 0, user );
HeapFree( GetProcessHeap(), 0, domain );
HeapFree( GetProcessHeap(), 0, passwd );
HeapFree( GetProcessHeap(), 0, identityW );
heap_free( package );
heap_free( user );
heap_free( domain );
heap_free( passwd );
heap_free( identityW );
return ret;
}
@ -217,8 +212,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
else if (phCredential)
{
handle = cred = (struct sec_handle *)phCredential->dwLower;
if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) )))
return SEC_E_INSUFFICIENT_MEMORY;
if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm;
}
@ -252,7 +246,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
}
}
HeapFree( GetProcessHeap(), 0, new_ctxt );
heap_free( new_ctxt );
return ret;
}
@ -276,14 +270,13 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA(
if (pszTargetName)
{
int target_len = MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, NULL, 0 );
target = HeapAlloc(GetProcessHeap(), 0, target_len * sizeof(SEC_WCHAR) );
if (!target) return SEC_E_INSUFFICIENT_MEMORY;
if (!(target = heap_alloc( target_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, target, target_len );
}
ret = nego_InitializeSecurityContextW( phCredential, phContext, target, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry );
HeapFree( GetProcessHeap(), 0, target );
heap_free( target );
return ret;
}
@ -309,8 +302,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
else if (phCredential)
{
handle = cred = (struct sec_handle *)phCredential->dwLower;
if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) )))
return SEC_E_INSUFFICIENT_MEMORY;
if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm;
}
@ -344,7 +336,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
}
}
HeapFree( GetProcessHeap(), 0, new_ctxt );
heap_free( new_ctxt );
return ret;
}
@ -384,7 +376,7 @@ static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContex
ret = ctxt->ntlm->fnTableW.DeleteSecurityContext( &ctxt->handle_ntlm );
}
TRACE( "freeing %p\n", ctxt );
HeapFree( GetProcessHeap(), 0, ctxt );
heap_free( ctxt );
return ret;
}
@ -543,7 +535,7 @@ static SECURITY_STATUS SEC_ENTRY nego_FreeCredentialsHandle(PCredHandle phCreden
if (cred->krb) cred->krb->fnTableW.FreeCredentialsHandle( &cred->handle_krb );
if (cred->ntlm) cred->ntlm->fnTableW.FreeCredentialsHandle( &cred->handle_ntlm );
HeapFree( GetProcessHeap(), 0, cred );
heap_free( cred );
return SEC_E_OK;
}

View File

@ -93,8 +93,7 @@ static char *ntlm_GetUsernameArg(LPCWSTR userW, INT userW_length)
unixcp_size = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS,
userW, userW_length, NULL, 0, NULL, NULL) + sizeof(username_arg);
user = HeapAlloc(GetProcessHeap(), 0, unixcp_size);
if (!user) return NULL;
if (!(user = heap_alloc(unixcp_size))) return NULL;
memcpy(user, username_arg, sizeof(username_arg) - 1);
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, userW, userW_length,
user + sizeof(username_arg) - 1,
@ -111,8 +110,7 @@ static char *ntlm_GetDomainArg(LPCWSTR domainW, INT domainW_length)
unixcp_size = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS,
domainW, domainW_length, NULL, 0, NULL, NULL) + sizeof(domain_arg);
domain = HeapAlloc(GetProcessHeap(), 0, unixcp_size);
if (!domain) return NULL;
if (!(domain = heap_alloc(unixcp_size))) return NULL;
memcpy(domain, domain_arg, sizeof(domain_arg) - 1);
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, domainW,
domainW_length, domain + sizeof(domain_arg) - 1,
@ -129,8 +127,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(
PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
SECURITY_STATUS ret;
PNtlmCredentials ntlm_cred;
SECURITY_STATUS ret = SEC_E_INSUFFICIENT_MEMORY;
PNtlmCredentials ntlm_cred = NULL;
LPWSTR domain = NULL, user = NULL, password = NULL;
PSEC_WINNT_AUTH_IDENTITY_W auth_data = NULL;
@ -138,149 +136,117 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleW(
debugstr_w(pszPrincipal), debugstr_w(pszPackage), fCredentialUse,
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
switch(fCredentialUse)
switch (fCredentialUse)
{
case SECPKG_CRED_INBOUND:
ntlm_cred = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntlm_cred));
if (!ntlm_cred)
ret = SEC_E_INSUFFICIENT_MEMORY;
case SECPKG_CRED_INBOUND:
if (!(ntlm_cred = heap_alloc(sizeof(*ntlm_cred)))) return SEC_E_INSUFFICIENT_MEMORY;
ntlm_cred->mode = NTLM_SERVER;
ntlm_cred->username_arg = NULL;
ntlm_cred->domain_arg = NULL;
ntlm_cred->password = NULL;
ntlm_cred->pwlen = 0;
ntlm_cred->no_cached_credentials = 0;
phCredential->dwUpper = fCredentialUse;
phCredential->dwLower = (ULONG_PTR)ntlm_cred;
ret = SEC_E_OK;
break;
case SECPKG_CRED_OUTBOUND:
auth_data = pAuthData;
if (!(ntlm_cred = heap_alloc(sizeof(*ntlm_cred)))) return SEC_E_INSUFFICIENT_MEMORY;
ntlm_cred->mode = NTLM_CLIENT;
ntlm_cred->username_arg = NULL;
ntlm_cred->domain_arg = NULL;
ntlm_cred->password = NULL;
ntlm_cred->pwlen = 0;
ntlm_cred->no_cached_credentials = 0;
if (pAuthData)
{
int domain_len = 0, user_len = 0, password_len = 0;
if (auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI)
{
if (auth_data->DomainLength)
{
domain_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain,
auth_data->DomainLength, NULL, 0);
if (!(domain = heap_alloc(sizeof(WCHAR) * domain_len))) goto done;
MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain, auth_data->DomainLength,
domain, domain_len);
}
if (auth_data->UserLength)
{
user_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User,
auth_data->UserLength, NULL, 0);
if (!(user = heap_alloc(sizeof(WCHAR) * user_len))) goto done;
MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User, auth_data->UserLength,
user, user_len);
}
if (auth_data->PasswordLength)
{
password_len = MultiByteToWideChar(CP_ACP, 0,(char *)auth_data->Password,
auth_data->PasswordLength, NULL, 0);
if (!(password = heap_alloc(sizeof(WCHAR) * password_len))) goto done;
MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Password, auth_data->PasswordLength,
password, password_len);
}
}
else
{
ntlm_cred->mode = NTLM_SERVER;
ntlm_cred->username_arg = NULL;
ntlm_cred->domain_arg = NULL;
ntlm_cred->password = NULL;
ntlm_cred->pwlen = 0;
ntlm_cred->no_cached_credentials = 0;
domain = auth_data->Domain;
domain_len = auth_data->DomainLength;
phCredential->dwUpper = fCredentialUse;
phCredential->dwLower = (ULONG_PTR)ntlm_cred;
ret = SEC_E_OK;
user = auth_data->User;
user_len = auth_data->UserLength;
password = auth_data->Password;
password_len = auth_data->PasswordLength;
}
break;
case SECPKG_CRED_OUTBOUND:
TRACE("Username is %s\n", debugstr_wn(user, user_len));
TRACE("Domain name is %s\n", debugstr_wn(domain, domain_len));
ntlm_cred->username_arg = ntlm_GetUsernameArg(user, user_len);
ntlm_cred->domain_arg = ntlm_GetDomainArg(domain, domain_len);
if (password_len)
{
auth_data = pAuthData;
ntlm_cred = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntlm_cred));
if (!ntlm_cred)
{
ret = SEC_E_INSUFFICIENT_MEMORY;
break;
}
ntlm_cred->mode = NTLM_CLIENT;
ntlm_cred->username_arg = NULL;
ntlm_cred->domain_arg = NULL;
ntlm_cred->password = NULL;
ntlm_cred->pwlen = 0;
ntlm_cred->no_cached_credentials = 0;
if(pAuthData != NULL)
{
int domain_len = 0, user_len = 0, password_len = 0;
if (auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI)
{
if (auth_data->DomainLength)
{
domain_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain,
auth_data->DomainLength, NULL, 0);
domain = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * domain_len);
if(!domain)
{
ret = SEC_E_INSUFFICIENT_MEMORY;
break;
}
MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Domain, auth_data->DomainLength,
domain, domain_len);
}
if (auth_data->UserLength)
{
user_len = MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User,
auth_data->UserLength, NULL, 0);
user = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * user_len);
if(!user)
{
ret = SEC_E_INSUFFICIENT_MEMORY;
break;
}
MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->User, auth_data->UserLength,
user, user_len);
}
if (auth_data->PasswordLength)
{
password_len = MultiByteToWideChar(CP_ACP, 0,(char *)auth_data->Password,
auth_data->PasswordLength, NULL, 0);
password = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR) * password_len);
if(!password)
{
ret = SEC_E_INSUFFICIENT_MEMORY;
break;
}
MultiByteToWideChar(CP_ACP, 0, (char *)auth_data->Password, auth_data->PasswordLength,
password, password_len);
}
}
else
{
domain = auth_data->Domain;
domain_len = auth_data->DomainLength;
user = auth_data->User;
user_len = auth_data->UserLength;
password = auth_data->Password;
password_len = auth_data->PasswordLength;
}
TRACE("Username is %s\n", debugstr_wn(user, user_len));
TRACE("Domain name is %s\n", debugstr_wn(domain, domain_len));
ntlm_cred->username_arg = ntlm_GetUsernameArg(user, user_len);
ntlm_cred->domain_arg = ntlm_GetDomainArg(domain, domain_len);
if(password_len != 0)
{
ntlm_cred->pwlen = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password,
password_len, NULL, 0, NULL, NULL);
ntlm_cred->password = HeapAlloc(GetProcessHeap(), 0,
ntlm_cred->pwlen);
if(!ntlm_cred->password)
{
ret = SEC_E_INSUFFICIENT_MEMORY;
break;
}
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password, password_len,
ntlm_cred->password, ntlm_cred->pwlen, NULL, NULL);
}
}
phCredential->dwUpper = fCredentialUse;
phCredential->dwLower = (ULONG_PTR)ntlm_cred;
TRACE("ACH phCredential->dwUpper: 0x%08lx, dwLower: 0x%08lx\n",
phCredential->dwUpper, phCredential->dwLower);
ret = SEC_E_OK;
break;
ntlm_cred->pwlen = WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password,
password_len, NULL, 0, NULL, NULL);
if (!(ntlm_cred->password = heap_alloc(ntlm_cred->pwlen))) goto done;
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS, password, password_len,
ntlm_cred->password, ntlm_cred->pwlen, NULL, NULL);
}
case SECPKG_CRED_BOTH:
FIXME("AcquireCredentialsHandle: SECPKG_CRED_BOTH stub\n");
ret = SEC_E_UNSUPPORTED_FUNCTION;
phCredential = NULL;
break;
default:
phCredential = NULL;
ret = SEC_E_UNKNOWN_CREDENTIALS;
}
phCredential->dwUpper = fCredentialUse;
phCredential->dwLower = (ULONG_PTR)ntlm_cred;
TRACE("ACH phCredential->dwUpper: 0x%08lx, dwLower: 0x%08lx\n", phCredential->dwUpper,
phCredential->dwLower);
ret = SEC_E_OK;
break;
case SECPKG_CRED_BOTH:
FIXME("AcquireCredentialsHandle: SECPKG_CRED_BOTH stub\n");
ret = SEC_E_UNSUPPORTED_FUNCTION;
break;
default:
ret = SEC_E_UNKNOWN_CREDENTIALS;
}
if (auth_data && auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI)
done:
if (auth_data && (auth_data->Flags & SEC_WINNT_AUTH_IDENTITY_ANSI))
{
HeapFree(GetProcessHeap(), 0, domain);
HeapFree(GetProcessHeap(), 0, user);
HeapFree(GetProcessHeap(), 0, password);
heap_free(domain);
heap_free(user);
heap_free(password);
}
if (ret != SEC_E_OK) heap_free( ntlm_cred );
return ret;
}
@ -292,81 +258,54 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(
PLUID pLogonID, PVOID pAuthData, SEC_GET_KEY_FN pGetKeyFn,
PVOID pGetKeyArgument, PCredHandle phCredential, PTimeStamp ptsExpiry)
{
SECURITY_STATUS ret;
SECURITY_STATUS ret = SEC_E_INSUFFICIENT_MEMORY;
int user_sizeW, domain_sizeW, passwd_sizeW;
SEC_WCHAR *user = NULL, *domain = NULL, *passwd = NULL, *package = NULL;
PSEC_WINNT_AUTH_IDENTITY_W pAuthDataW = NULL;
PSEC_WINNT_AUTH_IDENTITY_A identity = NULL;
PSEC_WINNT_AUTH_IDENTITY_A id = NULL;
TRACE("(%s, %s, 0x%08x, %p, %p, %p, %p, %p, %p)\n",
debugstr_a(pszPrincipal), debugstr_a(pszPackage), fCredentialUse,
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
if(pszPackage != NULL)
{
int package_sizeW = MultiByteToWideChar(CP_ACP, 0, pszPackage, -1,
NULL, 0);
package = HeapAlloc(GetProcessHeap(), 0, package_sizeW *
sizeof(SEC_WCHAR));
if (pszPackage)
{
int package_sizeW = MultiByteToWideChar(CP_ACP, 0, pszPackage, -1, NULL, 0);
if (!(package = heap_alloc(package_sizeW * sizeof(SEC_WCHAR)))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar(CP_ACP, 0, pszPackage, -1, package, package_sizeW);
}
if(pAuthData != NULL)
if (pAuthData)
{
identity = pAuthData;
if(identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
id = pAuthData;
if (id->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{
pAuthDataW = HeapAlloc(GetProcessHeap(), 0,
sizeof(SEC_WINNT_AUTH_IDENTITY_W));
if (!(pAuthDataW = heap_alloc(sizeof(SEC_WINNT_AUTH_IDENTITY_W)))) goto done;
if(identity->UserLength != 0)
{
user_sizeW = MultiByteToWideChar(CP_ACP, 0,
(LPCSTR)identity->User, identity->UserLength, NULL, 0);
user = HeapAlloc(GetProcessHeap(), 0, user_sizeW *
sizeof(SEC_WCHAR));
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)identity->User,
identity->UserLength, user, user_sizeW);
}
if (!id->UserLength) user_sizeW = 0;
else
{
user_sizeW = 0;
}
if(identity->DomainLength != 0)
{
domain_sizeW = MultiByteToWideChar(CP_ACP, 0,
(LPCSTR)identity->Domain, identity->DomainLength, NULL, 0);
domain = HeapAlloc(GetProcessHeap(), 0, domain_sizeW
* sizeof(SEC_WCHAR));
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)identity->Domain,
identity->DomainLength, domain, domain_sizeW);
}
else
{
domain_sizeW = 0;
user_sizeW = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->User, id->UserLength, NULL, 0);
if (!(user = heap_alloc(user_sizeW * sizeof(SEC_WCHAR)))) goto done;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->User, id->UserLength, user, user_sizeW);
}
if(identity->PasswordLength != 0)
{
passwd_sizeW = MultiByteToWideChar(CP_ACP, 0,
(LPCSTR)identity->Password, identity->PasswordLength,
NULL, 0);
passwd = HeapAlloc(GetProcessHeap(), 0, passwd_sizeW
* sizeof(SEC_WCHAR));
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)identity->Password,
identity->PasswordLength, passwd, passwd_sizeW);
}
if (!id->DomainLength) domain_sizeW = 0;
else
{
passwd_sizeW = 0;
domain_sizeW = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Domain, id->DomainLength, NULL, 0);
if (!(domain = heap_alloc(domain_sizeW * sizeof(SEC_WCHAR)))) goto done;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Domain, id->DomainLength, domain, domain_sizeW);
}
if (!id->PasswordLength) passwd_sizeW = 0;
else
{
passwd_sizeW = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Password, id->PasswordLength, NULL, 0);
if (!(passwd = heap_alloc(passwd_sizeW * sizeof(SEC_WCHAR)))) goto done;
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)id->Password, id->PasswordLength, passwd, passwd_sizeW);
}
pAuthDataW->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
pAuthDataW->User = user;
pAuthDataW->UserLength = user_sizeW;
@ -375,23 +314,20 @@ static SECURITY_STATUS SEC_ENTRY ntlm_AcquireCredentialsHandleA(
pAuthDataW->Password = passwd;
pAuthDataW->PasswordLength = passwd_sizeW;
}
else
{
pAuthDataW = (PSEC_WINNT_AUTH_IDENTITY_W)identity;
}
}
else pAuthDataW = (PSEC_WINNT_AUTH_IDENTITY_W)id;
}
ret = ntlm_AcquireCredentialsHandleW(NULL, package, fCredentialUse,
pLogonID, pAuthDataW, pGetKeyFn, pGetKeyArgument, phCredential,
ptsExpiry);
HeapFree(GetProcessHeap(), 0, package);
HeapFree(GetProcessHeap(), 0, user);
HeapFree(GetProcessHeap(), 0, domain);
HeapFree(GetProcessHeap(), 0, passwd);
if(pAuthDataW != (PSEC_WINNT_AUTH_IDENTITY_W)identity)
HeapFree(GetProcessHeap(), 0, pAuthDataW);
done:
heap_free(package);
heap_free(user);
heap_free(domain);
heap_free(passwd);
if (pAuthDataW != (PSEC_WINNT_AUTH_IDENTITY_W)id) heap_free(pAuthDataW);
return ret;
}
@ -465,16 +401,13 @@ static BOOL ntlm_GetCachedCredential(const SEC_WCHAR *pszTargetName, PCREDENTIAL
p = pszHost + strlenW(pszHost);
}
pszHostOnly = HeapAlloc(GetProcessHeap(), 0, (p - pszHost + 1) * sizeof(WCHAR));
if (!pszHostOnly)
return FALSE;
if (!(pszHostOnly = heap_alloc((p - pszHost + 1) * sizeof(WCHAR)))) return FALSE;
memcpy(pszHostOnly, pszHost, (p - pszHost) * sizeof(WCHAR));
pszHostOnly[p - pszHost] = '\0';
ret = CredReadW(pszHostOnly, CRED_TYPE_DOMAIN_PASSWORD, 0, cred);
HeapFree(GetProcessHeap(), 0, pszHostOnly);
heap_free(pszHostOnly);
return ret;
}
@ -521,8 +454,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
TRACE("Setting SECURITY_NETWORK_DREP\n");
}
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(char) * NTLM_MAX_BUF);
bin = HeapAlloc(GetProcessHeap(), 0, sizeof(BYTE) * NTLM_MAX_BUF);
buffer = heap_alloc(sizeof(char) * NTLM_MAX_BUF);
bin = heap_alloc(sizeof(BYTE) * NTLM_MAX_BUF);
if((phContext == NULL) && (pInput == NULL))
{
@ -582,8 +515,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
cred->CredentialBlobSize / sizeof(WCHAR), NULL, 0,
NULL, NULL);
password = HeapAlloc(GetProcessHeap(), 0, pwlen);
password = heap_alloc(pwlen);
WideCharToMultiByte(CP_UNIXCP, WC_NO_BEST_FIT_CHARS,
(LPWSTR)cred->CredentialBlob,
cred->CredentialBlobSize / sizeof(WCHAR),
@ -625,7 +557,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
goto isc_end;
helper->mode = NTLM_CLIENT;
helper->session_key = HeapAlloc(GetProcessHeap(), 0, 16);
helper->session_key = heap_alloc(16);
if (!helper->session_key)
{
cleanup_helper(helper);
@ -644,15 +576,13 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
password ? password : ntlm_cred->password,
password ? pwlen : ntlm_cred->pwlen,
NULL, 0);
unicode_password = HeapAlloc(GetProcessHeap(), 0,
passwd_lenW * sizeof(SEC_WCHAR));
unicode_password = heap_alloc(passwd_lenW * sizeof(SEC_WCHAR));
MultiByteToWideChar(CP_ACP, 0, password ? password : ntlm_cred->password,
password ? pwlen : ntlm_cred->pwlen, unicode_password, passwd_lenW);
SECUR32_CreateNTLM1SessionKey((PBYTE)unicode_password,
passwd_lenW * sizeof(SEC_WCHAR), helper->session_key);
HeapFree(GetProcessHeap(), 0, unicode_password);
heap_free(unicode_password);
}
else
memset(helper->session_key, 0, 16);
@ -661,8 +591,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
* "SF NTLMSSP_FEATURE_SIGN NTLMSSP_FEATURE_SEAL
* NTLMSSP_FEATURE_SESSION_KEY"
*/
want_flags = HeapAlloc(GetProcessHeap(), 0, 73);
if(want_flags == NULL)
if (!(want_flags = heap_alloc(73)))
{
cleanup_helper(helper);
ret = SEC_E_INSUFFICIENT_MEMORY;
@ -889,7 +818,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
if (fContextReq & ISC_REQ_ALLOCATE_MEMORY)
{
pOutput->pBuffers[token_idx].pvBuffer = HeapAlloc(GetProcessHeap(), 0, bin_len);
pOutput->pBuffers[token_idx].pvBuffer = heap_alloc(bin_len);
pOutput->pBuffers[token_idx].cbBuffer = bin_len;
}
else if (pOutput->pBuffers[token_idx].cbBuffer < bin_len)
@ -955,9 +884,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
TRACE("Failed to decode session key\n");
}
TRACE("Session key is %s\n", debugstr_a(buffer+3));
HeapFree(GetProcessHeap(), 0, helper->session_key);
helper->session_key = HeapAlloc(GetProcessHeap(), 0, bin_len);
if(!helper->session_key)
heap_free(helper->session_key);
if (!(helper->session_key = heap_alloc(bin_len)))
{
ret = SEC_E_INSUFFICIENT_MEMORY;
goto isc_end;
@ -980,12 +908,12 @@ SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextW(
}
isc_end:
HeapFree(GetProcessHeap(), 0, username);
HeapFree(GetProcessHeap(), 0, domain);
HeapFree(GetProcessHeap(), 0, password);
HeapFree(GetProcessHeap(), 0, want_flags);
HeapFree(GetProcessHeap(), 0, buffer);
HeapFree(GetProcessHeap(), 0, bin);
heap_free(username);
heap_free(domain);
heap_free(password);
heap_free(want_flags);
heap_free(buffer);
heap_free(bin);
return ret;
}
@ -1005,21 +933,18 @@ static SECURITY_STATUS SEC_ENTRY ntlm_InitializeSecurityContextA(
debugstr_a(pszTargetName), fContextReq, Reserved1, TargetDataRep, pInput,
Reserved1, phNewContext, pOutput, pfContextAttr, ptsExpiry);
if(pszTargetName != NULL)
if (pszTargetName)
{
int target_size = MultiByteToWideChar(CP_ACP, 0, pszTargetName,
strlen(pszTargetName)+1, NULL, 0);
target = HeapAlloc(GetProcessHeap(), 0, target_size *
sizeof(SEC_WCHAR));
MultiByteToWideChar(CP_ACP, 0, pszTargetName, strlen(pszTargetName)+1,
target, target_size);
int target_size = MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, NULL, 0);
if (!(target = heap_alloc(target_size * sizeof(SEC_WCHAR)))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, target, target_size);
}
ret = ntlm_InitializeSecurityContextW(phCredential, phContext, target,
fContextReq, Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry);
HeapFree(GetProcessHeap(), 0, target);
heap_free(target);
return ret;
}
@ -1043,8 +968,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
fContextReq, TargetDataRep, phNewContext, pOutput, pfContextAttr,
ptsExpiry);
buffer = HeapAlloc(GetProcessHeap(), 0, sizeof(char) * NTLM_MAX_BUF);
bin = HeapAlloc(GetProcessHeap(),0, sizeof(BYTE) * NTLM_MAX_BUF);
buffer = heap_alloc(sizeof(char) * NTLM_MAX_BUF);
bin = heap_alloc(sizeof(BYTE) * NTLM_MAX_BUF);
if(TargetDataRep == SECURITY_NETWORK_DREP){
TRACE("Using SECURITY_NETWORK_DREP\n");
@ -1101,8 +1026,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
helper->mode = NTLM_SERVER;
/* Handle all the flags */
want_flags = HeapAlloc(GetProcessHeap(), 0, 73);
if(want_flags == NULL)
if (!(want_flags = heap_alloc(73)))
{
TRACE("Failed to allocate memory for the want_flags!\n");
ret = SEC_E_INSUFFICIENT_MEMORY;
@ -1335,9 +1259,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
if(strncmp(buffer, "BH ", 3) == 0)
{
TRACE("Helper sent %s\n", debugstr_a(buffer+3));
HeapFree(GetProcessHeap(), 0, helper->session_key);
helper->session_key = HeapAlloc(GetProcessHeap(), 0, 16);
if (!helper->session_key)
heap_free(helper->session_key);
if (!(helper->session_key = heap_alloc(16)))
{
ret = SEC_E_INSUFFICIENT_MEMORY;
goto asc_end;
@ -1353,9 +1276,8 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
TRACE("Failed to decode session key\n");
}
TRACE("Session key is %s\n", debugstr_a(buffer+3));
HeapFree(GetProcessHeap(), 0, helper->session_key);
helper->session_key = HeapAlloc(GetProcessHeap(), 0, 16);
if(!helper->session_key)
heap_free(helper->session_key);
if (!(helper->session_key = heap_alloc(16)))
{
ret = SEC_E_INSUFFICIENT_MEMORY;
goto asc_end;
@ -1372,9 +1294,9 @@ SECURITY_STATUS SEC_ENTRY ntlm_AcceptSecurityContext(
phNewContext->dwLower = (ULONG_PTR)helper;
asc_end:
HeapFree(GetProcessHeap(), 0, want_flags);
HeapFree(GetProcessHeap(), 0, buffer);
HeapFree(GetProcessHeap(), 0, bin);
heap_free(want_flags);
heap_free(buffer);
heap_free(bin);
return ret;
}
@ -1411,10 +1333,10 @@ SECURITY_STATUS SEC_ENTRY ntlm_DeleteSecurityContext(PCtxtHandle phContext)
SECUR32_arc4Cleanup(helper->crypt.ntlm.a4i);
SECUR32_arc4Cleanup(helper->crypt.ntlm2.send_a4i);
SECUR32_arc4Cleanup(helper->crypt.ntlm2.recv_a4i);
HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.send_sign_key);
HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.send_seal_key);
HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.recv_sign_key);
HeapFree(GetProcessHeap(), 0, helper->crypt.ntlm2.recv_seal_key);
heap_free(helper->crypt.ntlm2.send_sign_key);
heap_free(helper->crypt.ntlm2.send_seal_key);
heap_free(helper->crypt.ntlm2.recv_sign_key);
heap_free(helper->crypt.ntlm2.recv_seal_key);
cleanup_helper(helper);
@ -1473,7 +1395,7 @@ static SecPkgInfoW *build_package_infoW( const SecPkgInfoW *info )
DWORD size_name = (strlenW(info->Name) + 1) * sizeof(WCHAR);
DWORD size_comment = (strlenW(info->Comment) + 1) * sizeof(WCHAR);
if (!(ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) + size_name + size_comment ))) return NULL;
if (!(ret = heap_alloc( sizeof(*ret) + size_name + size_comment ))) return NULL;
ret->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID;
@ -1490,7 +1412,7 @@ static SecPkgInfoA *build_package_infoA( const SecPkgInfoA *info )
SecPkgInfoA *ret;
DWORD size_name = strlen(info->Name) + 1, size_comment = strlen(info->Comment) + 1;
if (!(ret = HeapAlloc( GetProcessHeap(), 0, sizeof(*ret) + size_name + size_comment ))) return NULL;
if (!(ret = heap_alloc( sizeof(*ret) + size_name + size_comment ))) return NULL;
ret->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID;
@ -1822,7 +1744,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
helper = (PNegoHelper)phContext->dwLower;
TRACE("Negotiated flags: 0x%08x\n", helper->neg_flags);
local_buff = HeapAlloc(GetProcessHeap(), 0, pMessage->cBuffers * sizeof(SecBuffer));
local_buff = heap_alloc(pMessage->cBuffers * sizeof(SecBuffer));
local_desc.ulVersion = SECBUFFER_VERSION;
local_desc.cBuffers = pMessage->cBuffers;
@ -1853,8 +1775,7 @@ SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
else
ret = SEC_E_OK;
HeapFree(GetProcessHeap(), 0, local_buff);
heap_free(local_buff);
return ret;
}
@ -1864,24 +1785,19 @@ SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
*/
SECURITY_STATUS SEC_ENTRY ntlm_FreeCredentialsHandle(PCredHandle phCredential)
{
SECURITY_STATUS ret;
if(phCredential){
if (phCredential)
{
PNtlmCredentials ntlm_cred = (PNtlmCredentials) phCredential->dwLower;
phCredential->dwUpper = 0;
phCredential->dwLower = 0;
if (ntlm_cred->password)
memset(ntlm_cred->password, 0, ntlm_cred->pwlen);
HeapFree(GetProcessHeap(), 0, ntlm_cred->password);
HeapFree(GetProcessHeap(), 0, ntlm_cred->username_arg);
HeapFree(GetProcessHeap(), 0, ntlm_cred->domain_arg);
HeapFree(GetProcessHeap(), 0, ntlm_cred);
ret = SEC_E_OK;
if (ntlm_cred->password) memset(ntlm_cred->password, 0, ntlm_cred->pwlen);
heap_free(ntlm_cred->password);
heap_free(ntlm_cred->username_arg);
heap_free(ntlm_cred->domain_arg);
heap_free(ntlm_cred);
}
else
ret = SEC_E_OK;
return ret;
return SEC_E_OK;
}
/***********************************************************************

View File

@ -97,7 +97,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type)
{
/* Grow the table */
SIZE_T new_size = schan_handle_table_size + (schan_handle_table_size >> 1);
struct schan_handle *new_table = HeapReAlloc(GetProcessHeap(), 0, schan_handle_table, new_size * sizeof(*schan_handle_table));
struct schan_handle *new_table = heap_realloc(schan_handle_table, new_size * sizeof(*schan_handle_table));
if (!new_table)
{
ERR("Failed to grow the handle table\n");
@ -423,7 +423,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
/* For now, the only thing I'm interested in is the direction of the
* connection, so just store it.
*/
creds = HeapAlloc(GetProcessHeap(), 0, sizeof(*creds));
creds = heap_alloc(sizeof(*creds));
if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
@ -450,7 +450,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return st;
fail:
HeapFree(GetProcessHeap(), 0, creds);
heap_free(creds);
return SEC_E_INTERNAL_ERROR;
}
@ -469,14 +469,14 @@ static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schan
ULONG_PTR handle;
struct schan_credentials *creds;
creds = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*creds));
creds = heap_alloc_zero(sizeof(*creds));
if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
creds->credential_use = SECPKG_CRED_INBOUND;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
if (handle == SCHAN_INVALID_HANDLE)
{
HeapFree(GetProcessHeap(), 0, creds);
heap_free(creds);
return SEC_E_INTERNAL_ERROR;
}
@ -540,7 +540,7 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle(
if (creds->credential_use == SECPKG_CRED_OUTBOUND)
schan_imp_free_certificate_credentials(creds);
HeapFree(GetProcessHeap(), 0, creds);
heap_free(creds);
return SEC_E_OK;
}
@ -581,9 +581,9 @@ static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T mi
while (new_size < min_size) new_size *= 2;
if (b->pvBuffer)
new_data = HeapReAlloc(GetProcessHeap(), 0, b->pvBuffer, new_size);
new_data = heap_realloc(b->pvBuffer, new_size);
else
new_data = HeapAlloc(GetProcessHeap(), 0, new_size);
new_data = heap_alloc(new_size);
if (!new_data)
{
@ -815,21 +815,21 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
return SEC_E_INVALID_HANDLE;
}
ctx = HeapAlloc(GetProcessHeap(), 0, sizeof(*ctx));
ctx = heap_alloc(sizeof(*ctx));
if (!ctx) return SEC_E_INSUFFICIENT_MEMORY;
ctx->cert = NULL;
handle = schan_alloc_handle(ctx, SCHAN_HANDLE_CTX);
if (handle == SCHAN_INVALID_HANDLE)
{
HeapFree(GetProcessHeap(), 0, ctx);
heap_free(ctx);
return SEC_E_INTERNAL_ERROR;
}
if (!schan_imp_create_session(&ctx->session, cred))
{
schan_free_handle(handle, SCHAN_HANDLE_CTX);
HeapFree(GetProcessHeap(), 0, ctx);
heap_free(ctx);
return SEC_E_INTERNAL_ERROR;
}
@ -839,13 +839,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
if (pszTargetName && *pszTargetName)
{
UINT len = WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, NULL, 0, NULL, NULL );
char *target = HeapAlloc( GetProcessHeap(), 0, len );
char *target = heap_alloc( len );
if (target)
{
WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, target, len, NULL, NULL );
schan_imp_set_session_target( ctx->session, target );
HeapFree( GetProcessHeap(), 0, target );
heap_free( target );
}
}
phNewContext->dwLower = handle;
@ -950,7 +950,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
if (pszTargetName)
{
INT len = MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, NULL, 0);
target_name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*target_name));
if (!(target_name = heap_alloc(len * sizeof(*target_name)))) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, target_name, len);
}
@ -958,8 +958,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
fContextReq, Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry);
HeapFree(GetProcessHeap(), 0, target_name);
heap_free(target_name);
return ret;
}
@ -1104,7 +1103,7 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
return GetLastError();
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix)-1 + hash_size;
bindings->Bindings = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bindings->BindingsLength);
bindings->Bindings = heap_alloc_zero(bindings->BindingsLength);
if(!bindings->Bindings)
return SEC_E_INSUFFICIENT_MEMORY;
@ -1232,7 +1231,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
buffer = &message->pBuffers[idx];
data_size = buffer->cbBuffer;
data = HeapAlloc(GetProcessHeap(), 0, data_size);
data = heap_alloc(data_size);
memcpy(data, buffer->pvBuffer, data_size);
if (schan_find_sec_buffer_idx(message, 0, SECBUFFER_STREAM_HEADER) != -1)
@ -1250,7 +1249,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
b = &ctx->transport.out;
b->desc->pBuffers[b->current_buffer_idx].cbBuffer = b->offset;
HeapFree(GetProcessHeap(), 0, data);
heap_free(data);
TRACE("Returning %#x.\n", status);
@ -1365,7 +1364,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
}
data_size = expected_size - 5;
data = HeapAlloc(GetProcessHeap(), 0, data_size);
data = heap_alloc(data_size);
init_schan_buffers(&ctx->transport.in, message, schan_decrypt_message_get_next_buffer);
ctx->transport.in.limit = expected_size;
@ -1380,7 +1379,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
if (status != SEC_E_OK)
{
HeapFree(GetProcessHeap(), 0, data);
heap_free(data);
ERR("Returning %x\n", status);
return status;
}
@ -1394,7 +1393,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
TRACE("Received %ld bytes\n", received);
memcpy(buf_ptr + 5, data, received);
HeapFree(GetProcessHeap(), 0, data);
heap_free(data);
schan_decrypt_fill_buffer(message, SECBUFFER_DATA,
buf_ptr + 5, received);
@ -1426,7 +1425,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context
if (ctx->cert)
CertFreeCertificateContext(ctx->cert);
schan_imp_dispose_session(ctx->session);
HeapFree(GetProcessHeap(), 0, ctx);
heap_free(ctx);
return SEC_E_OK;
}
@ -1526,7 +1525,7 @@ void SECUR32_initSchannelSP(void)
if (!schan_imp_init())
return;
schan_handle_table = HeapAlloc(GetProcessHeap(), 0, 64 * sizeof(*schan_handle_table));
schan_handle_table = heap_alloc(64 * sizeof(*schan_handle_table));
if (!schan_handle_table)
{
ERR("Failed to allocate schannel handle table.\n");
@ -1546,7 +1545,7 @@ void SECUR32_initSchannelSP(void)
return;
fail:
HeapFree(GetProcessHeap(), 0, schan_handle_table);
heap_free(schan_handle_table);
schan_handle_table = NULL;
schan_imp_deinit();
return;
@ -1566,7 +1565,7 @@ void SECUR32_deinitSchannelSP(void)
{
struct schan_context *ctx = schan_free_handle(i, SCHAN_HANDLE_CTX);
schan_imp_dispose_session(ctx->session);
HeapFree(GetProcessHeap(), 0, ctx);
heap_free(ctx);
}
}
i = schan_handle_count;
@ -1577,10 +1576,10 @@ void SECUR32_deinitSchannelSP(void)
struct schan_credentials *cred;
cred = schan_free_handle(i, SCHAN_HANDLE_CRED);
schan_imp_free_certificate_credentials(cred);
HeapFree(GetProcessHeap(), 0, cred);
heap_free(cred);
}
}
HeapFree(GetProcessHeap(), 0, schan_handle_table);
heap_free(schan_handle_table);
schan_imp_deinit();
}

View File

@ -739,7 +739,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
TRACE("(%p)\n", session);
s = HeapAlloc(GetProcessHeap(), 0, sizeof(*s));
s = heap_alloc(sizeof(*s));
if (!s)
return FALSE;
@ -793,7 +793,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
return TRUE;
fail:
HeapFree(GetProcessHeap(), 0, s);
heap_free(s);
return FALSE;
}
@ -808,7 +808,7 @@ void schan_imp_dispose_session(schan_imp_session session)
if (status != noErr)
ERR("Failed to dispose of session context: %d\n", status);
DeleteCriticalSection(&s->cs);
HeapFree(GetProcessHeap(), 0, s);
heap_free(s);
}
void schan_imp_set_session_transport(schan_imp_session session,

View File

@ -178,7 +178,7 @@ static PWSTR SECUR32_strdupW(PCWSTR str)
if (str)
{
ret = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR));
ret = heap_alloc((lstrlenW(str) + 1) * sizeof(WCHAR));
if (ret)
lstrcpyW(ret, str);
}
@ -197,7 +197,7 @@ PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str)
if (charsNeeded)
{
ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded * sizeof(WCHAR));
ret = heap_alloc(charsNeeded * sizeof(WCHAR));
if (ret)
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded);
}
@ -220,7 +220,7 @@ PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str)
if (charsNeeded)
{
ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded);
ret = heap_alloc(charsNeeded);
if (ret)
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded,
NULL, NULL);
@ -406,7 +406,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
if (!providerTable)
{
providerTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProviderTable));
providerTable = heap_alloc(sizeof(SecureProviderTable));
if (!providerTable)
{
LeaveCriticalSection(&cs);
@ -416,7 +416,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
list_init(&providerTable->table);
}
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProvider));
ret = heap_alloc(sizeof(SecureProvider));
if (!ret)
{
LeaveCriticalSection(&cs);
@ -455,7 +455,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
if (!packageTable)
{
packageTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackageTable));
packageTable = heap_alloc(sizeof(SecurePackageTable));
if (!packageTable)
{
LeaveCriticalSection(&cs);
@ -468,7 +468,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
for (i = 0; i < toAdd; i++)
{
SecurePackage *package = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackage));
SecurePackage *package = heap_alloc(sizeof(SecurePackage));
if (!package)
continue;
@ -685,12 +685,12 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE(package, package_next, &packageTable->table,
SecurePackage, entry)
{
HeapFree(GetProcessHeap(), 0, package->infoW.Name);
HeapFree(GetProcessHeap(), 0, package->infoW.Comment);
HeapFree(GetProcessHeap(), 0, package);
heap_free(package->infoW.Name);
heap_free(package->infoW.Comment);
heap_free(package);
}
HeapFree(GetProcessHeap(), 0, packageTable);
heap_free(packageTable);
packageTable = NULL;
}
@ -700,13 +700,13 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE(provider, provider_next, &providerTable->table,
SecureProvider, entry)
{
HeapFree(GetProcessHeap(), 0, provider->moduleName);
heap_free(provider->moduleName);
if (provider->lib)
FreeLibrary(provider->lib);
HeapFree(GetProcessHeap(), 0, provider);
heap_free(provider);
}
HeapFree(GetProcessHeap(), 0, providerTable);
heap_free(providerTable);
providerTable = NULL;
}
@ -723,8 +723,7 @@ static void SECUR32_freeProviders(void)
*/
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
{
HeapFree(GetProcessHeap(), 0, pv);
heap_free(pv);
return SEC_E_OK;
}
@ -756,7 +755,7 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages,
}
if (bytesNeeded)
{
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
*ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo)
{
ULONG i = 0;
@ -821,7 +820,7 @@ static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages,
bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment,
-1, NULL, 0, NULL, NULL);
}
ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
ret = heap_alloc(bytesNeeded);
if (ret)
{
PSTR nextString;
@ -924,7 +923,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) {
bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
bufferW = heap_alloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@ -938,7 +937,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
}
else
*nSize = sizeW;
HeapFree(GetProcessHeap(), 0, bufferW);
heap_free(bufferW);
return rc;
}
@ -1081,7 +1080,7 @@ BOOLEAN WINAPI GetUserNameExA(
ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) {
bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR));
bufferW = heap_alloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@ -1104,7 +1103,7 @@ BOOLEAN WINAPI GetUserNameExA(
}
else
*nSize = sizeW;
HeapFree(GetProcessHeap(), 0, bufferW);
heap_free(bufferW);
return rc;
}

View File

@ -23,6 +23,7 @@
#include <sys/types.h>
#include <limits.h>
#include "wine/heap.h"
#include "wine/list.h"
#include "schannel.h"

View File

@ -76,8 +76,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW(
ret = AcquireCredentialsHandleA(principal, package, fCredentialsUse,
pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential,
ptsExpiry);
HeapFree(GetProcessHeap(), 0, principal);
HeapFree(GetProcessHeap(), 0, package);
heap_free(principal);
heap_free(package);
}
else
ret = SEC_E_SECPKG_NOT_FOUND;
@ -259,7 +259,7 @@ SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextW(
phCredential, phContext, target, fContextReq, Reserved1,
TargetDataRep, pInput, Reserved2, phNewContext, pOutput,
pfContextAttr, ptsExpiry);
HeapFree(GetProcessHeap(), 0, target);
heap_free(target);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@ -337,8 +337,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsW(PCredHandle hCredentials,
ret = package->provider->fnTableA.AddCredentialsA(
cred, szPrincipal, szPackage, fCredentialUse, pAuthData,
pGetKeyFn, pvGetKeyArgument, ptsExpiry);
HeapFree(GetProcessHeap(), 0, szPrincipal);
HeapFree(GetProcessHeap(), 0, szPackage);
heap_free(szPrincipal);
heap_free(szPackage);
}
else
ret = SEC_E_UNSUPPORTED_FUNCTION;
@ -372,7 +372,7 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW)
NULL, 0, NULL, NULL);
bytesNeeded += commentLen;
}
ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
ret = heap_alloc(bytesNeeded);
if (ret)
{
PSTR nextString = (PSTR)((PBYTE)ret + sizeof(SecPkgInfoA));
@ -597,7 +597,7 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA)
NULL, 0);
bytesNeeded += commentLen * sizeof(WCHAR);
}
ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
ret = heap_alloc(bytesNeeded);
if (ret)
{
PWSTR nextString = (PWSTR)((PBYTE)ret + sizeof(SecPkgInfoW));
@ -894,6 +894,6 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextW(
TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
phContext);
ret = ImportSecurityContextA(package, pPackedContext, Token, phContext);
HeapFree(GetProcessHeap(), 0, package);
heap_free(package);
return ret;
}

View File

@ -157,10 +157,10 @@ static void SECUR32_CalcNTLM2Subkey(const BYTE *session_key, const char *magic,
/* This assumes we do have a valid NTLM2 user session key */
SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper)
{
helper->crypt.ntlm2.send_sign_key = HeapAlloc(GetProcessHeap(), 0, 16);
helper->crypt.ntlm2.send_seal_key = HeapAlloc(GetProcessHeap(), 0, 16);
helper->crypt.ntlm2.recv_sign_key = HeapAlloc(GetProcessHeap(), 0, 16);
helper->crypt.ntlm2.recv_seal_key = HeapAlloc(GetProcessHeap(), 0, 16);
helper->crypt.ntlm2.send_sign_key = heap_alloc(16);
helper->crypt.ntlm2.send_seal_key = heap_alloc(16);
helper->crypt.ntlm2.recv_sign_key = heap_alloc(16);
helper->crypt.ntlm2.recv_seal_key = heap_alloc(16);
if(helper->mode == NTLM_CLIENT)
{
@ -190,7 +190,7 @@ SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper)
arc4_info *SECUR32_arc4Alloc(void)
{
arc4_info *a4i = HeapAlloc(GetProcessHeap(), 0, sizeof(arc4_info));
arc4_info *a4i = heap_alloc(sizeof(arc4_info));
return a4i;
}
@ -247,5 +247,5 @@ void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length)
void SECUR32_arc4Cleanup(arc4_info *a4i)
{
HeapFree(GetProcessHeap(), 0, a4i);
heap_free(a4i);
}

View File

@ -41,7 +41,7 @@ static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
if (phSec && package && realHandle)
{
PSecHandle newSec = HeapAlloc(GetProcessHeap(), 0, sizeof(SecHandle));
PSecHandle newSec = heap_alloc(sizeof(SecHandle));
if (newSec)
{
@ -169,7 +169,7 @@ SECURITY_STATUS WINAPI FreeCredentialsHandle(
ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
else
ret = SEC_E_INVALID_HANDLE;
HeapFree(GetProcessHeap(), 0, cred);
heap_free(cred);
}
else
ret = SEC_E_INVALID_HANDLE;
@ -468,7 +468,7 @@ SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
else
ret = SEC_E_INVALID_HANDLE;
HeapFree(GetProcessHeap(), 0, ctxt);
heap_free(ctxt);
}
else
ret = SEC_E_INVALID_HANDLE;
@ -713,7 +713,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
package->infoW.Comment, -1, NULL, 0, NULL, NULL);
bytesNeeded += commentLen;
}
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
*ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo)
{
PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
@ -775,7 +775,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
commentLen = lstrlenW(package->infoW.Comment) + 1;
bytesNeeded += commentLen * sizeof(WCHAR);
}
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded);
*ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo)
{
PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +