Commit f0db5677 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

secur32: Use the global memory allocation helpers.

parent 63b9fb35
...@@ -81,7 +81,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog, ...@@ -81,7 +81,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
fcntl( pipe_out[1], F_SETFD, FD_CLOEXEC ); 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[0]);
close(pipe_in[1]); close(pipe_in[1]);
...@@ -98,7 +98,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog, ...@@ -98,7 +98,7 @@ SECURITY_STATUS fork_helper(PNegoHelper *new_helper, const char *prog,
close(pipe_in[1]); close(pipe_in[1]);
close(pipe_out[0]); close(pipe_out[0]);
close(pipe_out[1]); close(pipe_out[1]);
HeapFree( GetProcessHeap(), 0, helper ); heap_free( helper );
return SEC_E_INTERNAL_ERROR; return SEC_E_INTERNAL_ERROR;
} }
...@@ -156,7 +156,7 @@ static SECURITY_STATUS read_line(PNegoHelper helper, int *offset_len) ...@@ -156,7 +156,7 @@ static SECURITY_STATUS read_line(PNegoHelper helper, int *offset_len)
if(helper->com_buf == NULL) if(helper->com_buf == NULL)
{ {
TRACE("Creating a new buffer for the helper\n"); 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; return SEC_E_INSUFFICIENT_MEMORY;
/* Created a new buffer, size is INITIAL_BUFFER_SIZE, offset is 0 */ /* 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) ...@@ -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) if(helper->com_buf_offset + INITIAL_BUFFER_SIZE > helper->com_buf_size)
{ {
/* increment buffer size in INITIAL_BUFFER_SIZE steps */ /* increment buffer size in INITIAL_BUFFER_SIZE steps */
char *buf = HeapReAlloc(GetProcessHeap(), 0, helper->com_buf, char *buf = heap_realloc(helper->com_buf, helper->com_buf_size + INITIAL_BUFFER_SIZE);
helper->com_buf_size + INITIAL_BUFFER_SIZE);
TRACE("Resizing buffer!\n"); TRACE("Resizing buffer!\n");
if (!buf) return SEC_E_INSUFFICIENT_MEMORY; if (!buf) return SEC_E_INSUFFICIENT_MEMORY;
helper->com_buf_size += INITIAL_BUFFER_SIZE; helper->com_buf_size += INITIAL_BUFFER_SIZE;
...@@ -280,8 +279,8 @@ void cleanup_helper(PNegoHelper helper) ...@@ -280,8 +279,8 @@ void cleanup_helper(PNegoHelper helper)
if(helper == NULL) if(helper == NULL)
return; return;
HeapFree(GetProcessHeap(), 0, helper->com_buf); heap_free(helper->com_buf);
HeapFree(GetProcessHeap(), 0, helper->session_key); heap_free(helper->session_key);
/* closing stdin will terminate ntlm_auth */ /* closing stdin will terminate ntlm_auth */
close(helper->pipe_out); close(helper->pipe_out);
...@@ -297,7 +296,7 @@ void cleanup_helper(PNegoHelper helper) ...@@ -297,7 +296,7 @@ void cleanup_helper(PNegoHelper helper)
} }
#endif #endif
HeapFree(GetProcessHeap(), 0, helper); heap_free(helper);
} }
void check_version(PNegoHelper helper) void check_version(PNegoHelper helper)
......
...@@ -94,7 +94,7 @@ NTSTATUS WINAPI LsaConnectUntrusted(PHANDLE LsaHandle) ...@@ -94,7 +94,7 @@ NTSTATUS WINAPI LsaConnectUntrusted(PHANDLE LsaHandle)
TRACE("%p\n", 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; if (!lsa_conn) return STATUS_NO_MEMORY;
lsa_conn->magic = LSA_MAGIC; lsa_conn->magic = LSA_MAGIC;
...@@ -122,7 +122,7 @@ NTSTATUS WINAPI LsaEnumerateLogonSessions(PULONG LogonSessionCount, ...@@ -122,7 +122,7 @@ NTSTATUS WINAPI LsaEnumerateLogonSessions(PULONG LogonSessionCount,
NTSTATUS WINAPI LsaFreeReturnBuffer(PVOID buffer) NTSTATUS WINAPI LsaFreeReturnBuffer(PVOID buffer)
{ {
TRACE("%p\n", buffer); TRACE("%p\n", buffer);
HeapFree(GetProcessHeap(), 0, buffer); heap_free(buffer);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -186,26 +186,26 @@ static NTSTATUS NTAPI lsa_DeleteCredential(LUID *logon_id, ULONG package_id, LSA ...@@ -186,26 +186,26 @@ static NTSTATUS NTAPI lsa_DeleteCredential(LUID *logon_id, ULONG package_id, LSA
static void * NTAPI lsa_AllocateLsaHeap(ULONG size) static void * NTAPI lsa_AllocateLsaHeap(ULONG size)
{ {
TRACE("%u\n", size); TRACE("%u\n", size);
return HeapAlloc(GetProcessHeap(), 0, size); return heap_alloc(size);
} }
static void NTAPI lsa_FreeLsaHeap(void *p) static void NTAPI lsa_FreeLsaHeap(void *p)
{ {
TRACE("%p\n", 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) static NTSTATUS NTAPI lsa_AllocateClientBuffer(PLSA_CLIENT_REQUEST req, ULONG size, void **p)
{ {
TRACE("%p,%u,%p\n", req, size, 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; return *p ? STATUS_SUCCESS : STATUS_NO_MEMORY;
} }
static NTSTATUS NTAPI lsa_FreeClientBuffer(PLSA_CLIENT_REQUEST req, void *p) static NTSTATUS NTAPI lsa_FreeClientBuffer(PLSA_CLIENT_REQUEST req, void *p)
{ {
TRACE("%p,%p\n", req, p); TRACE("%p,%p\n", req, p);
HeapFree(GetProcessHeap(), 0, p); heap_free(p);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -328,13 +328,13 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA( ...@@ -328,13 +328,13 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (principal) if (principal)
{ {
int len = MultiByteToWideChar( CP_ACP, 0, principal, -1, NULL, 0 ); 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 ); MultiByteToWideChar( CP_ACP, 0, principal, -1, principalW, len );
} }
if (package) if (package)
{ {
int len = MultiByteToWideChar( CP_ACP, 0, package, -1, NULL, 0 ); 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 ); MultiByteToWideChar( CP_ACP, 0, package, -1, packageW, len );
} }
if (auth_data) if (auth_data)
...@@ -343,23 +343,23 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA( ...@@ -343,23 +343,23 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
if (id->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI) 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) if (id->UserLength)
{ {
len_user = MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, NULL, 0 ); 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 ); MultiByteToWideChar( CP_ACP, 0, (char *)id->User, id->UserLength, user, len_user );
} }
if (id->DomainLength) if (id->DomainLength)
{ {
len_domain = MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, NULL, 0 ); 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 ); MultiByteToWideChar( CP_ACP, 0, (char *)id->Domain, id->DomainLength, domain, len_domain );
} }
if (id->PasswordLength) if (id->PasswordLength)
{ {
len_passwd = MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, NULL, 0 ); 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 ); MultiByteToWideChar( CP_ACP, 0, (char *)id->Password, id->PasswordLength, passwd, len_passwd );
} }
auth_dataW->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE; auth_dataW->Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
...@@ -376,12 +376,12 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA( ...@@ -376,12 +376,12 @@ static SECURITY_STATUS WINAPI lsa_AcquireCredentialsHandleA(
status = lsa_AcquireCredentialsHandleW( principalW, packageW, credentials_use, logon_id, auth_dataW, get_key_fn, status = lsa_AcquireCredentialsHandleW( principalW, packageW, credentials_use, logon_id, auth_dataW, get_key_fn,
get_key_arg, credential, ts_expiry ); get_key_arg, credential, ts_expiry );
done: done:
if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) HeapFree( GetProcessHeap(), 0, auth_dataW ); if (auth_dataW != (SEC_WINNT_AUTH_IDENTITY_W *)id) heap_free( auth_dataW );
HeapFree( GetProcessHeap(), 0, packageW ); heap_free( packageW );
HeapFree( GetProcessHeap(), 0, principalW ); heap_free( principalW );
HeapFree( GetProcessHeap(), 0, user ); heap_free( user );
HeapFree( GetProcessHeap(), 0, domain ); heap_free( domain );
HeapFree( GetProcessHeap(), 0, passwd ); heap_free( passwd );
return status; return status;
} }
...@@ -464,13 +464,13 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA( ...@@ -464,13 +464,13 @@ static SECURITY_STATUS WINAPI lsa_InitializeSecurityContextA(
if (target_name) if (target_name)
{ {
int len = MultiByteToWideChar( CP_ACP, 0, target_name, -1, NULL, 0 ); 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 ); MultiByteToWideChar( CP_ACP, 0, target_name, -1, targetW, len );
} }
status = lsa_InitializeSecurityContextW( credential, context, targetW, context_req, reserved1, target_data_rep, status = lsa_InitializeSecurityContextW( credential, context, targetW, context_req, reserved1, target_data_rep,
input, reserved2, new_context, output, context_attr, ts_expiry ); input, reserved2, new_context, output, context_attr, ts_expiry );
HeapFree( GetProcessHeap(), 0, targetW ); heap_free( targetW );
return status; return status;
} }
...@@ -560,7 +560,7 @@ static SecPkgInfoA *package_infoWtoA( const SecPkgInfoW *info ) ...@@ -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_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 ); 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->fCapabilities = info->fCapabilities;
ret->wVersion = info->wVersion; ret->wVersion = info->wVersion;
ret->wRPCID = info->wRPCID; ret->wRPCID = info->wRPCID;
...@@ -778,9 +778,9 @@ static void add_package(struct lsa_package *package) ...@@ -778,9 +778,9 @@ static void add_package(struct lsa_package *package)
struct lsa_package *new_loaded_packages; struct lsa_package *new_loaded_packages;
if (!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 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) if (new_loaded_packages)
{ {
...@@ -884,7 +884,7 @@ void load_auth_packages(void) ...@@ -884,7 +884,7 @@ void load_auth_packages(void)
{ {
SecPkgInfoW *info; 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) if (info)
{ {
NTSTATUS status; NTSTATUS status;
...@@ -893,7 +893,7 @@ void load_auth_packages(void) ...@@ -893,7 +893,7 @@ void load_auth_packages(void)
if (status == STATUS_SUCCESS) if (status == STATUS_SUCCESS)
SECUR32_addPackages(provider, loaded_packages[i].lsa_table_count, NULL, info); SECUR32_addPackages(provider, loaded_packages[i].lsa_table_count, NULL, info);
HeapFree(GetProcessHeap(), 0, info); heap_free(info);
} }
} }
} }
......
...@@ -77,7 +77,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW( ...@@ -77,7 +77,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry); pLogonID, pAuthData, pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry);
if (!pszPackage) return SEC_E_SECPKG_NOT_FOUND; 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 ))) if ((package = SECUR32_findPackageW( kerberosW )))
{ {
...@@ -105,7 +105,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW( ...@@ -105,7 +105,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleW(
return SEC_E_OK; return SEC_E_OK;
} }
HeapFree( GetProcessHeap(), 0, cred ); heap_free( cred );
return ret; return ret;
} }
...@@ -128,8 +128,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA( ...@@ -128,8 +128,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (pszPackage) if (pszPackage)
{ {
int package_len = MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, NULL, 0 ); int package_len = MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, NULL, 0 );
package = HeapAlloc( GetProcessHeap(), 0, package_len * sizeof(SEC_WCHAR) ); if (!(package = heap_alloc( package_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
if (!package) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, package, package_len ); MultiByteToWideChar( CP_ACP, 0, pszPackage, -1, package, package_len );
} }
if (pAuthData) if (pAuthData)
...@@ -139,16 +138,14 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA( ...@@ -139,16 +138,14 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
if (identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI) if (identity->Flags == SEC_WINNT_AUTH_IDENTITY_ANSI)
{ {
identityW = HeapAlloc( GetProcessHeap(), 0, sizeof(*identityW) ); if (!(identityW = heap_alloc( sizeof(*identityW) ))) goto done;
if (!identityW) goto done;
if (!identity->UserLength) user_len = 0; if (!identity->UserLength) user_len = 0;
else else
{ {
user_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User, user_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User,
identity->UserLength, NULL, 0 ); identity->UserLength, NULL, 0 );
user = HeapAlloc( GetProcessHeap(), 0, user_len * sizeof(SEC_WCHAR) ); if (!(user = heap_alloc( user_len * sizeof(SEC_WCHAR) ))) goto done;
if (!user) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User, identity->UserLength, MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->User, identity->UserLength,
user, user_len ); user, user_len );
} }
...@@ -157,8 +154,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA( ...@@ -157,8 +154,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{ {
domain_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain, domain_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain,
identity->DomainLength, NULL, 0 ); identity->DomainLength, NULL, 0 );
domain = HeapAlloc( GetProcessHeap(), 0, domain_len * sizeof(SEC_WCHAR) ); if (!(domain = heap_alloc( domain_len * sizeof(SEC_WCHAR) ))) goto done;
if (!domain) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain, identity->DomainLength, MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Domain, identity->DomainLength,
domain, domain_len ); domain, domain_len );
} }
...@@ -167,8 +163,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA( ...@@ -167,8 +163,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
{ {
passwd_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password, passwd_len = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password,
identity->PasswordLength, NULL, 0 ); identity->PasswordLength, NULL, 0 );
passwd = HeapAlloc( GetProcessHeap(), 0, passwd_len * sizeof(SEC_WCHAR) ); if (!(passwd = heap_alloc( passwd_len * sizeof(SEC_WCHAR) ))) goto done;
if (!passwd) goto done;
MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password, identity->PasswordLength, MultiByteToWideChar( CP_ACP, 0, (LPCSTR)identity->Password, identity->PasswordLength,
passwd, passwd_len ); passwd, passwd_len );
} }
...@@ -185,11 +180,11 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA( ...@@ -185,11 +180,11 @@ static SECURITY_STATUS SEC_ENTRY nego_AcquireCredentialsHandleA(
ret = nego_AcquireCredentialsHandleW( NULL, package, fCredentialUse, pLogonID, identityW, ret = nego_AcquireCredentialsHandleW( NULL, package, fCredentialUse, pLogonID, identityW,
pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry ); pGetKeyFn, pGetKeyArgument, phCredential, ptsExpiry );
done: done:
HeapFree( GetProcessHeap(), 0, package ); heap_free( package );
HeapFree( GetProcessHeap(), 0, user ); heap_free( user );
HeapFree( GetProcessHeap(), 0, domain ); heap_free( domain );
HeapFree( GetProcessHeap(), 0, passwd ); heap_free( passwd );
HeapFree( GetProcessHeap(), 0, identityW ); heap_free( identityW );
return ret; return ret;
} }
...@@ -217,8 +212,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW( ...@@ -217,8 +212,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
else if (phCredential) else if (phCredential)
{ {
handle = cred = (struct sec_handle *)phCredential->dwLower; handle = cred = (struct sec_handle *)phCredential->dwLower;
if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) ))) if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb; ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm; ctxt->ntlm = cred->ntlm;
} }
...@@ -252,7 +246,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW( ...@@ -252,7 +246,7 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextW(
} }
} }
HeapFree( GetProcessHeap(), 0, new_ctxt ); heap_free( new_ctxt );
return ret; return ret;
} }
...@@ -276,14 +270,13 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA( ...@@ -276,14 +270,13 @@ static SECURITY_STATUS SEC_ENTRY nego_InitializeSecurityContextA(
if (pszTargetName) if (pszTargetName)
{ {
int target_len = MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, NULL, 0 ); int target_len = MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, NULL, 0 );
target = HeapAlloc(GetProcessHeap(), 0, target_len * sizeof(SEC_WCHAR) ); if (!(target = heap_alloc( target_len * sizeof(SEC_WCHAR) ))) return SEC_E_INSUFFICIENT_MEMORY;
if (!target) return SEC_E_INSUFFICIENT_MEMORY;
MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, target, target_len ); MultiByteToWideChar( CP_ACP, 0, pszTargetName, -1, target, target_len );
} }
ret = nego_InitializeSecurityContextW( phCredential, phContext, target, fContextReq, ret = nego_InitializeSecurityContextW( phCredential, phContext, target, fContextReq,
Reserved1, TargetDataRep, pInput, Reserved2, Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry ); phNewContext, pOutput, pfContextAttr, ptsExpiry );
HeapFree( GetProcessHeap(), 0, target ); heap_free( target );
return ret; return ret;
} }
...@@ -309,8 +302,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext( ...@@ -309,8 +302,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
else if (phCredential) else if (phCredential)
{ {
handle = cred = (struct sec_handle *)phCredential->dwLower; handle = cred = (struct sec_handle *)phCredential->dwLower;
if (!(new_ctxt = ctxt = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctxt) ))) if (!(new_ctxt = ctxt = heap_alloc_zero( sizeof(*ctxt) ))) return SEC_E_INSUFFICIENT_MEMORY;
return SEC_E_INSUFFICIENT_MEMORY;
ctxt->krb = cred->krb; ctxt->krb = cred->krb;
ctxt->ntlm = cred->ntlm; ctxt->ntlm = cred->ntlm;
} }
...@@ -344,7 +336,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext( ...@@ -344,7 +336,7 @@ static SECURITY_STATUS SEC_ENTRY nego_AcceptSecurityContext(
} }
} }
HeapFree( GetProcessHeap(), 0, new_ctxt ); heap_free( new_ctxt );
return ret; return ret;
} }
...@@ -384,7 +376,7 @@ static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContex ...@@ -384,7 +376,7 @@ static SECURITY_STATUS SEC_ENTRY nego_DeleteSecurityContext(PCtxtHandle phContex
ret = ctxt->ntlm->fnTableW.DeleteSecurityContext( &ctxt->handle_ntlm ); ret = ctxt->ntlm->fnTableW.DeleteSecurityContext( &ctxt->handle_ntlm );
} }
TRACE( "freeing %p\n", ctxt ); TRACE( "freeing %p\n", ctxt );
HeapFree( GetProcessHeap(), 0, ctxt ); heap_free( ctxt );
return ret; return ret;
} }
...@@ -543,7 +535,7 @@ static SECURITY_STATUS SEC_ENTRY nego_FreeCredentialsHandle(PCredHandle phCreden ...@@ -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->krb) cred->krb->fnTableW.FreeCredentialsHandle( &cred->handle_krb );
if (cred->ntlm) cred->ntlm->fnTableW.FreeCredentialsHandle( &cred->handle_ntlm ); if (cred->ntlm) cred->ntlm->fnTableW.FreeCredentialsHandle( &cred->handle_ntlm );
HeapFree( GetProcessHeap(), 0, cred ); heap_free( cred );
return SEC_E_OK; return SEC_E_OK;
} }
......
...@@ -97,7 +97,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type) ...@@ -97,7 +97,7 @@ static ULONG_PTR schan_alloc_handle(void *object, enum schan_handle_type type)
{ {
/* Grow the table */ /* Grow the table */
SIZE_T new_size = schan_handle_table_size + (schan_handle_table_size >> 1); 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) if (!new_table)
{ {
ERR("Failed to grow the handle table\n"); ERR("Failed to grow the handle table\n");
...@@ -423,7 +423,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan ...@@ -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 /* For now, the only thing I'm interested in is the direction of the
* connection, so just store it. * connection, so just store it.
*/ */
creds = HeapAlloc(GetProcessHeap(), 0, sizeof(*creds)); creds = heap_alloc(sizeof(*creds));
if (!creds) return SEC_E_INSUFFICIENT_MEMORY; if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED); handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
...@@ -450,7 +450,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan ...@@ -450,7 +450,7 @@ static SECURITY_STATUS schan_AcquireClientCredentials(const SCHANNEL_CRED *schan
return st; return st;
fail: fail:
HeapFree(GetProcessHeap(), 0, creds); heap_free(creds);
return SEC_E_INTERNAL_ERROR; return SEC_E_INTERNAL_ERROR;
} }
...@@ -469,14 +469,14 @@ static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schan ...@@ -469,14 +469,14 @@ static SECURITY_STATUS schan_AcquireServerCredentials(const SCHANNEL_CRED *schan
ULONG_PTR handle; ULONG_PTR handle;
struct schan_credentials *creds; 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; if (!creds) return SEC_E_INSUFFICIENT_MEMORY;
creds->credential_use = SECPKG_CRED_INBOUND; creds->credential_use = SECPKG_CRED_INBOUND;
handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED); handle = schan_alloc_handle(creds, SCHAN_HANDLE_CRED);
if (handle == SCHAN_INVALID_HANDLE) if (handle == SCHAN_INVALID_HANDLE)
{ {
HeapFree(GetProcessHeap(), 0, creds); heap_free(creds);
return SEC_E_INTERNAL_ERROR; return SEC_E_INTERNAL_ERROR;
} }
...@@ -540,7 +540,7 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle( ...@@ -540,7 +540,7 @@ static SECURITY_STATUS SEC_ENTRY schan_FreeCredentialsHandle(
if (creds->credential_use == SECPKG_CRED_OUTBOUND) if (creds->credential_use == SECPKG_CRED_OUTBOUND)
schan_imp_free_certificate_credentials(creds); schan_imp_free_certificate_credentials(creds);
HeapFree(GetProcessHeap(), 0, creds); heap_free(creds);
return SEC_E_OK; return SEC_E_OK;
} }
...@@ -581,9 +581,9 @@ static void schan_resize_current_buffer(const struct schan_buffers *s, SIZE_T mi ...@@ -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; while (new_size < min_size) new_size *= 2;
if (b->pvBuffer) if (b->pvBuffer)
new_data = HeapReAlloc(GetProcessHeap(), 0, b->pvBuffer, new_size); new_data = heap_realloc(b->pvBuffer, new_size);
else else
new_data = HeapAlloc(GetProcessHeap(), 0, new_size); new_data = heap_alloc(new_size);
if (!new_data) if (!new_data)
{ {
...@@ -815,21 +815,21 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW( ...@@ -815,21 +815,21 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
return SEC_E_INVALID_HANDLE; return SEC_E_INVALID_HANDLE;
} }
ctx = HeapAlloc(GetProcessHeap(), 0, sizeof(*ctx)); ctx = heap_alloc(sizeof(*ctx));
if (!ctx) return SEC_E_INSUFFICIENT_MEMORY; if (!ctx) return SEC_E_INSUFFICIENT_MEMORY;
ctx->cert = NULL; ctx->cert = NULL;
handle = schan_alloc_handle(ctx, SCHAN_HANDLE_CTX); handle = schan_alloc_handle(ctx, SCHAN_HANDLE_CTX);
if (handle == SCHAN_INVALID_HANDLE) if (handle == SCHAN_INVALID_HANDLE)
{ {
HeapFree(GetProcessHeap(), 0, ctx); heap_free(ctx);
return SEC_E_INTERNAL_ERROR; return SEC_E_INTERNAL_ERROR;
} }
if (!schan_imp_create_session(&ctx->session, cred)) if (!schan_imp_create_session(&ctx->session, cred))
{ {
schan_free_handle(handle, SCHAN_HANDLE_CTX); schan_free_handle(handle, SCHAN_HANDLE_CTX);
HeapFree(GetProcessHeap(), 0, ctx); heap_free(ctx);
return SEC_E_INTERNAL_ERROR; return SEC_E_INTERNAL_ERROR;
} }
...@@ -839,13 +839,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW( ...@@ -839,13 +839,13 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextW(
if (pszTargetName && *pszTargetName) if (pszTargetName && *pszTargetName)
{ {
UINT len = WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, NULL, 0, NULL, NULL ); 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) if (target)
{ {
WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, target, len, NULL, NULL ); WideCharToMultiByte( CP_UNIXCP, 0, pszTargetName, -1, target, len, NULL, NULL );
schan_imp_set_session_target( ctx->session, target ); schan_imp_set_session_target( ctx->session, target );
HeapFree( GetProcessHeap(), 0, target ); heap_free( target );
} }
} }
phNewContext->dwLower = handle; phNewContext->dwLower = handle;
...@@ -950,7 +950,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA( ...@@ -950,7 +950,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
if (pszTargetName) if (pszTargetName)
{ {
INT len = MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, NULL, 0); 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); MultiByteToWideChar(CP_ACP, 0, pszTargetName, -1, target_name, len);
} }
...@@ -958,8 +958,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA( ...@@ -958,8 +958,7 @@ static SECURITY_STATUS SEC_ENTRY schan_InitializeSecurityContextA(
fContextReq, Reserved1, TargetDataRep, pInput, Reserved2, fContextReq, Reserved1, TargetDataRep, pInput, Reserved2,
phNewContext, pOutput, pfContextAttr, ptsExpiry); phNewContext, pOutput, pfContextAttr, ptsExpiry);
HeapFree(GetProcessHeap(), 0, target_name); heap_free(target_name);
return ret; return ret;
} }
...@@ -1104,7 +1103,7 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW( ...@@ -1104,7 +1103,7 @@ static SECURITY_STATUS SEC_ENTRY schan_QueryContextAttributesW(
return GetLastError(); return GetLastError();
bindings->BindingsLength = sizeof(*bindings->Bindings) + sizeof(prefix)-1 + hash_size; 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) if(!bindings->Bindings)
return SEC_E_INSUFFICIENT_MEMORY; return SEC_E_INSUFFICIENT_MEMORY;
...@@ -1232,7 +1231,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle ...@@ -1232,7 +1231,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
buffer = &message->pBuffers[idx]; buffer = &message->pBuffers[idx];
data_size = buffer->cbBuffer; data_size = buffer->cbBuffer;
data = HeapAlloc(GetProcessHeap(), 0, data_size); data = heap_alloc(data_size);
memcpy(data, buffer->pvBuffer, data_size); memcpy(data, buffer->pvBuffer, data_size);
if (schan_find_sec_buffer_idx(message, 0, SECBUFFER_STREAM_HEADER) != -1) 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 ...@@ -1250,7 +1249,7 @@ static SECURITY_STATUS SEC_ENTRY schan_EncryptMessage(PCtxtHandle context_handle
b = &ctx->transport.out; b = &ctx->transport.out;
b->desc->pBuffers[b->current_buffer_idx].cbBuffer = b->offset; b->desc->pBuffers[b->current_buffer_idx].cbBuffer = b->offset;
HeapFree(GetProcessHeap(), 0, data); heap_free(data);
TRACE("Returning %#x.\n", status); TRACE("Returning %#x.\n", status);
...@@ -1365,7 +1364,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle ...@@ -1365,7 +1364,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
} }
data_size = expected_size - 5; 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); init_schan_buffers(&ctx->transport.in, message, schan_decrypt_message_get_next_buffer);
ctx->transport.in.limit = expected_size; ctx->transport.in.limit = expected_size;
...@@ -1380,7 +1379,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle ...@@ -1380,7 +1379,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
if (status != SEC_E_OK) if (status != SEC_E_OK)
{ {
HeapFree(GetProcessHeap(), 0, data); heap_free(data);
ERR("Returning %x\n", status); ERR("Returning %x\n", status);
return status; return status;
} }
...@@ -1394,7 +1393,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle ...@@ -1394,7 +1393,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DecryptMessage(PCtxtHandle context_handle
TRACE("Received %ld bytes\n", received); TRACE("Received %ld bytes\n", received);
memcpy(buf_ptr + 5, data, received); memcpy(buf_ptr + 5, data, received);
HeapFree(GetProcessHeap(), 0, data); heap_free(data);
schan_decrypt_fill_buffer(message, SECBUFFER_DATA, schan_decrypt_fill_buffer(message, SECBUFFER_DATA,
buf_ptr + 5, received); buf_ptr + 5, received);
...@@ -1426,7 +1425,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context ...@@ -1426,7 +1425,7 @@ static SECURITY_STATUS SEC_ENTRY schan_DeleteSecurityContext(PCtxtHandle context
if (ctx->cert) if (ctx->cert)
CertFreeCertificateContext(ctx->cert); CertFreeCertificateContext(ctx->cert);
schan_imp_dispose_session(ctx->session); schan_imp_dispose_session(ctx->session);
HeapFree(GetProcessHeap(), 0, ctx); heap_free(ctx);
return SEC_E_OK; return SEC_E_OK;
} }
...@@ -1526,7 +1525,7 @@ void SECUR32_initSchannelSP(void) ...@@ -1526,7 +1525,7 @@ void SECUR32_initSchannelSP(void)
if (!schan_imp_init()) if (!schan_imp_init())
return; 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) if (!schan_handle_table)
{ {
ERR("Failed to allocate schannel handle table.\n"); ERR("Failed to allocate schannel handle table.\n");
...@@ -1546,7 +1545,7 @@ void SECUR32_initSchannelSP(void) ...@@ -1546,7 +1545,7 @@ void SECUR32_initSchannelSP(void)
return; return;
fail: fail:
HeapFree(GetProcessHeap(), 0, schan_handle_table); heap_free(schan_handle_table);
schan_handle_table = NULL; schan_handle_table = NULL;
schan_imp_deinit(); schan_imp_deinit();
return; return;
...@@ -1566,7 +1565,7 @@ void SECUR32_deinitSchannelSP(void) ...@@ -1566,7 +1565,7 @@ void SECUR32_deinitSchannelSP(void)
{ {
struct schan_context *ctx = schan_free_handle(i, SCHAN_HANDLE_CTX); struct schan_context *ctx = schan_free_handle(i, SCHAN_HANDLE_CTX);
schan_imp_dispose_session(ctx->session); schan_imp_dispose_session(ctx->session);
HeapFree(GetProcessHeap(), 0, ctx); heap_free(ctx);
} }
} }
i = schan_handle_count; i = schan_handle_count;
...@@ -1577,10 +1576,10 @@ void SECUR32_deinitSchannelSP(void) ...@@ -1577,10 +1576,10 @@ void SECUR32_deinitSchannelSP(void)
struct schan_credentials *cred; struct schan_credentials *cred;
cred = schan_free_handle(i, SCHAN_HANDLE_CRED); cred = schan_free_handle(i, SCHAN_HANDLE_CRED);
schan_imp_free_certificate_credentials(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(); schan_imp_deinit();
} }
......
...@@ -739,7 +739,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre ...@@ -739,7 +739,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
TRACE("(%p)\n", session); TRACE("(%p)\n", session);
s = HeapAlloc(GetProcessHeap(), 0, sizeof(*s)); s = heap_alloc(sizeof(*s));
if (!s) if (!s)
return FALSE; return FALSE;
...@@ -793,7 +793,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre ...@@ -793,7 +793,7 @@ BOOL schan_imp_create_session(schan_imp_session *session, schan_credentials *cre
return TRUE; return TRUE;
fail: fail:
HeapFree(GetProcessHeap(), 0, s); heap_free(s);
return FALSE; return FALSE;
} }
...@@ -808,7 +808,7 @@ void schan_imp_dispose_session(schan_imp_session session) ...@@ -808,7 +808,7 @@ void schan_imp_dispose_session(schan_imp_session session)
if (status != noErr) if (status != noErr)
ERR("Failed to dispose of session context: %d\n", status); ERR("Failed to dispose of session context: %d\n", status);
DeleteCriticalSection(&s->cs); DeleteCriticalSection(&s->cs);
HeapFree(GetProcessHeap(), 0, s); heap_free(s);
} }
void schan_imp_set_session_transport(schan_imp_session session, void schan_imp_set_session_transport(schan_imp_session session,
......
...@@ -178,7 +178,7 @@ static PWSTR SECUR32_strdupW(PCWSTR str) ...@@ -178,7 +178,7 @@ static PWSTR SECUR32_strdupW(PCWSTR str)
if (str) if (str)
{ {
ret = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR)); ret = heap_alloc((lstrlenW(str) + 1) * sizeof(WCHAR));
if (ret) if (ret)
lstrcpyW(ret, str); lstrcpyW(ret, str);
} }
...@@ -197,7 +197,7 @@ PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str) ...@@ -197,7 +197,7 @@ PWSTR SECUR32_AllocWideFromMultiByte(PCSTR str)
if (charsNeeded) if (charsNeeded)
{ {
ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded * sizeof(WCHAR)); ret = heap_alloc(charsNeeded * sizeof(WCHAR));
if (ret) if (ret)
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded); MultiByteToWideChar(CP_ACP, 0, str, -1, ret, charsNeeded);
} }
...@@ -220,7 +220,7 @@ PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str) ...@@ -220,7 +220,7 @@ PSTR SECUR32_AllocMultiByteFromWide(PCWSTR str)
if (charsNeeded) if (charsNeeded)
{ {
ret = HeapAlloc(GetProcessHeap(), 0, charsNeeded); ret = heap_alloc(charsNeeded);
if (ret) if (ret)
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded, WideCharToMultiByte(CP_ACP, 0, str, -1, ret, charsNeeded,
NULL, NULL); NULL, NULL);
...@@ -406,7 +406,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA, ...@@ -406,7 +406,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
if (!providerTable) if (!providerTable)
{ {
providerTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProviderTable)); providerTable = heap_alloc(sizeof(SecureProviderTable));
if (!providerTable) if (!providerTable)
{ {
LeaveCriticalSection(&cs); LeaveCriticalSection(&cs);
...@@ -416,7 +416,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA, ...@@ -416,7 +416,7 @@ SecureProvider *SECUR32_addProvider(const SecurityFunctionTableA *fnTableA,
list_init(&providerTable->table); list_init(&providerTable->table);
} }
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(SecureProvider)); ret = heap_alloc(sizeof(SecureProvider));
if (!ret) if (!ret)
{ {
LeaveCriticalSection(&cs); LeaveCriticalSection(&cs);
...@@ -455,7 +455,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd, ...@@ -455,7 +455,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
if (!packageTable) if (!packageTable)
{ {
packageTable = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackageTable)); packageTable = heap_alloc(sizeof(SecurePackageTable));
if (!packageTable) if (!packageTable)
{ {
LeaveCriticalSection(&cs); LeaveCriticalSection(&cs);
...@@ -468,7 +468,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd, ...@@ -468,7 +468,7 @@ void SECUR32_addPackages(SecureProvider *provider, ULONG toAdd,
for (i = 0; i < toAdd; i++) for (i = 0; i < toAdd; i++)
{ {
SecurePackage *package = HeapAlloc(GetProcessHeap(), 0, sizeof(SecurePackage)); SecurePackage *package = heap_alloc(sizeof(SecurePackage));
if (!package) if (!package)
continue; continue;
...@@ -685,12 +685,12 @@ static void SECUR32_freeProviders(void) ...@@ -685,12 +685,12 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE(package, package_next, &packageTable->table, LIST_FOR_EACH_ENTRY_SAFE(package, package_next, &packageTable->table,
SecurePackage, entry) SecurePackage, entry)
{ {
HeapFree(GetProcessHeap(), 0, package->infoW.Name); heap_free(package->infoW.Name);
HeapFree(GetProcessHeap(), 0, package->infoW.Comment); heap_free(package->infoW.Comment);
HeapFree(GetProcessHeap(), 0, package); heap_free(package);
} }
HeapFree(GetProcessHeap(), 0, packageTable); heap_free(packageTable);
packageTable = NULL; packageTable = NULL;
} }
...@@ -700,13 +700,13 @@ static void SECUR32_freeProviders(void) ...@@ -700,13 +700,13 @@ static void SECUR32_freeProviders(void)
LIST_FOR_EACH_ENTRY_SAFE(provider, provider_next, &providerTable->table, LIST_FOR_EACH_ENTRY_SAFE(provider, provider_next, &providerTable->table,
SecureProvider, entry) SecureProvider, entry)
{ {
HeapFree(GetProcessHeap(), 0, provider->moduleName); heap_free(provider->moduleName);
if (provider->lib) if (provider->lib)
FreeLibrary(provider->lib); FreeLibrary(provider->lib);
HeapFree(GetProcessHeap(), 0, provider); heap_free(provider);
} }
HeapFree(GetProcessHeap(), 0, providerTable); heap_free(providerTable);
providerTable = NULL; providerTable = NULL;
} }
...@@ -723,8 +723,7 @@ static void SECUR32_freeProviders(void) ...@@ -723,8 +723,7 @@ static void SECUR32_freeProviders(void)
*/ */
SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv) SECURITY_STATUS WINAPI FreeContextBuffer(PVOID pv)
{ {
HeapFree(GetProcessHeap(), 0, pv); heap_free(pv);
return SEC_E_OK; return SEC_E_OK;
} }
...@@ -756,7 +755,7 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages, ...@@ -756,7 +755,7 @@ SECURITY_STATUS WINAPI EnumerateSecurityPackagesW(PULONG pcPackages,
} }
if (bytesNeeded) if (bytesNeeded)
{ {
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); *ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo) if (*ppPackageInfo)
{ {
ULONG i = 0; ULONG i = 0;
...@@ -821,7 +820,7 @@ static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages, ...@@ -821,7 +820,7 @@ static PSecPkgInfoA thunk_PSecPkgInfoWToA(ULONG cPackages,
bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment, bytesNeeded += WideCharToMultiByte(CP_ACP, 0, info[i].Comment,
-1, NULL, 0, NULL, NULL); -1, NULL, 0, NULL, NULL);
} }
ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); ret = heap_alloc(bytesNeeded);
if (ret) if (ret)
{ {
PSTR nextString; PSTR nextString;
...@@ -924,7 +923,7 @@ BOOLEAN WINAPI GetComputerObjectNameA( ...@@ -924,7 +923,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
ULONG sizeW = *nSize; ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize); TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) { if (lpNameBuffer) {
bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR)); bufferW = heap_alloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) { if (bufferW == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
...@@ -938,7 +937,7 @@ BOOLEAN WINAPI GetComputerObjectNameA( ...@@ -938,7 +937,7 @@ BOOLEAN WINAPI GetComputerObjectNameA(
} }
else else
*nSize = sizeW; *nSize = sizeW;
HeapFree(GetProcessHeap(), 0, bufferW); heap_free(bufferW);
return rc; return rc;
} }
...@@ -1081,7 +1080,7 @@ BOOLEAN WINAPI GetUserNameExA( ...@@ -1081,7 +1080,7 @@ BOOLEAN WINAPI GetUserNameExA(
ULONG sizeW = *nSize; ULONG sizeW = *nSize;
TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize); TRACE("(%d %p %p)\n", NameFormat, lpNameBuffer, nSize);
if (lpNameBuffer) { if (lpNameBuffer) {
bufferW = HeapAlloc(GetProcessHeap(), 0, sizeW * sizeof(WCHAR)); bufferW = heap_alloc(sizeW * sizeof(WCHAR));
if (bufferW == NULL) { if (bufferW == NULL) {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE; return FALSE;
...@@ -1104,7 +1103,7 @@ BOOLEAN WINAPI GetUserNameExA( ...@@ -1104,7 +1103,7 @@ BOOLEAN WINAPI GetUserNameExA(
} }
else else
*nSize = sizeW; *nSize = sizeW;
HeapFree(GetProcessHeap(), 0, bufferW); heap_free(bufferW);
return rc; return rc;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <limits.h> #include <limits.h>
#include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
#include "schannel.h" #include "schannel.h"
......
...@@ -76,8 +76,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW( ...@@ -76,8 +76,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AcquireCredentialsHandleW(
ret = AcquireCredentialsHandleA(principal, package, fCredentialsUse, ret = AcquireCredentialsHandleA(principal, package, fCredentialsUse,
pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential, pvLogonID, pAuthData, pGetKeyFn, pvGetKeyArgument, phCredential,
ptsExpiry); ptsExpiry);
HeapFree(GetProcessHeap(), 0, principal); heap_free(principal);
HeapFree(GetProcessHeap(), 0, package); heap_free(package);
} }
else else
ret = SEC_E_SECPKG_NOT_FOUND; ret = SEC_E_SECPKG_NOT_FOUND;
...@@ -259,7 +259,7 @@ SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextW( ...@@ -259,7 +259,7 @@ SECURITY_STATUS SEC_ENTRY thunk_InitializeSecurityContextW(
phCredential, phContext, target, fContextReq, Reserved1, phCredential, phContext, target, fContextReq, Reserved1,
TargetDataRep, pInput, Reserved2, phNewContext, pOutput, TargetDataRep, pInput, Reserved2, phNewContext, pOutput,
pfContextAttr, ptsExpiry); pfContextAttr, ptsExpiry);
HeapFree(GetProcessHeap(), 0, target); heap_free(target);
} }
else else
ret = SEC_E_UNSUPPORTED_FUNCTION; ret = SEC_E_UNSUPPORTED_FUNCTION;
...@@ -337,8 +337,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsW(PCredHandle hCredentials, ...@@ -337,8 +337,8 @@ SECURITY_STATUS SEC_ENTRY thunk_AddCredentialsW(PCredHandle hCredentials,
ret = package->provider->fnTableA.AddCredentialsA( ret = package->provider->fnTableA.AddCredentialsA(
cred, szPrincipal, szPackage, fCredentialUse, pAuthData, cred, szPrincipal, szPackage, fCredentialUse, pAuthData,
pGetKeyFn, pvGetKeyArgument, ptsExpiry); pGetKeyFn, pvGetKeyArgument, ptsExpiry);
HeapFree(GetProcessHeap(), 0, szPrincipal); heap_free(szPrincipal);
HeapFree(GetProcessHeap(), 0, szPackage); heap_free(szPackage);
} }
else else
ret = SEC_E_UNSUPPORTED_FUNCTION; ret = SEC_E_UNSUPPORTED_FUNCTION;
...@@ -372,7 +372,7 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW) ...@@ -372,7 +372,7 @@ static PSecPkgInfoA _copyPackageInfoFlatWToA(const SecPkgInfoW *infoW)
NULL, 0, NULL, NULL); NULL, 0, NULL, NULL);
bytesNeeded += commentLen; bytesNeeded += commentLen;
} }
ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); ret = heap_alloc(bytesNeeded);
if (ret) if (ret)
{ {
PSTR nextString = (PSTR)((PBYTE)ret + sizeof(SecPkgInfoA)); PSTR nextString = (PSTR)((PBYTE)ret + sizeof(SecPkgInfoA));
...@@ -597,7 +597,7 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA) ...@@ -597,7 +597,7 @@ static PSecPkgInfoW _copyPackageInfoFlatAToW(const SecPkgInfoA *infoA)
NULL, 0); NULL, 0);
bytesNeeded += commentLen * sizeof(WCHAR); bytesNeeded += commentLen * sizeof(WCHAR);
} }
ret = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); ret = heap_alloc(bytesNeeded);
if (ret) if (ret)
{ {
PWSTR nextString = (PWSTR)((PBYTE)ret + sizeof(SecPkgInfoW)); PWSTR nextString = (PWSTR)((PBYTE)ret + sizeof(SecPkgInfoW));
...@@ -894,6 +894,6 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextW( ...@@ -894,6 +894,6 @@ SECURITY_STATUS SEC_ENTRY thunk_ImportSecurityContextW(
TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token, TRACE("%s %p %p %p\n", debugstr_w(pszPackage), pPackedContext, Token,
phContext); phContext);
ret = ImportSecurityContextA(package, pPackedContext, Token, phContext); ret = ImportSecurityContextA(package, pPackedContext, Token, phContext);
HeapFree(GetProcessHeap(), 0, package); heap_free(package);
return ret; return ret;
} }
...@@ -157,10 +157,10 @@ static void SECUR32_CalcNTLM2Subkey(const BYTE *session_key, const char *magic, ...@@ -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 */ /* This assumes we do have a valid NTLM2 user session key */
SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper) SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper)
{ {
helper->crypt.ntlm2.send_sign_key = HeapAlloc(GetProcessHeap(), 0, 16); helper->crypt.ntlm2.send_sign_key = heap_alloc(16);
helper->crypt.ntlm2.send_seal_key = HeapAlloc(GetProcessHeap(), 0, 16); helper->crypt.ntlm2.send_seal_key = heap_alloc(16);
helper->crypt.ntlm2.recv_sign_key = HeapAlloc(GetProcessHeap(), 0, 16); helper->crypt.ntlm2.recv_sign_key = heap_alloc(16);
helper->crypt.ntlm2.recv_seal_key = HeapAlloc(GetProcessHeap(), 0, 16); helper->crypt.ntlm2.recv_seal_key = heap_alloc(16);
if(helper->mode == NTLM_CLIENT) if(helper->mode == NTLM_CLIENT)
{ {
...@@ -190,7 +190,7 @@ SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper) ...@@ -190,7 +190,7 @@ SECURITY_STATUS SECUR32_CreateNTLM2SubKeys(PNegoHelper helper)
arc4_info *SECUR32_arc4Alloc(void) arc4_info *SECUR32_arc4Alloc(void)
{ {
arc4_info *a4i = HeapAlloc(GetProcessHeap(), 0, sizeof(arc4_info)); arc4_info *a4i = heap_alloc(sizeof(arc4_info));
return a4i; return a4i;
} }
...@@ -247,5 +247,5 @@ void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length) ...@@ -247,5 +247,5 @@ void SECUR32_arc4Process(arc4_info *a4i, BYTE *inoutString, unsigned int length)
void SECUR32_arc4Cleanup(arc4_info *a4i) void SECUR32_arc4Cleanup(arc4_info *a4i)
{ {
HeapFree(GetProcessHeap(), 0, a4i); heap_free(a4i);
} }
...@@ -41,7 +41,7 @@ static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec, ...@@ -41,7 +41,7 @@ static SECURITY_STATUS SECUR32_makeSecHandle(PSecHandle phSec,
if (phSec && package && realHandle) if (phSec && package && realHandle)
{ {
PSecHandle newSec = HeapAlloc(GetProcessHeap(), 0, sizeof(SecHandle)); PSecHandle newSec = heap_alloc(sizeof(SecHandle));
if (newSec) if (newSec)
{ {
...@@ -169,7 +169,7 @@ SECURITY_STATUS WINAPI FreeCredentialsHandle( ...@@ -169,7 +169,7 @@ SECURITY_STATUS WINAPI FreeCredentialsHandle(
ret = package->provider->fnTableW.FreeCredentialsHandle(cred); ret = package->provider->fnTableW.FreeCredentialsHandle(cred);
else else
ret = SEC_E_INVALID_HANDLE; ret = SEC_E_INVALID_HANDLE;
HeapFree(GetProcessHeap(), 0, cred); heap_free(cred);
} }
else else
ret = SEC_E_INVALID_HANDLE; ret = SEC_E_INVALID_HANDLE;
...@@ -468,7 +468,7 @@ SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext) ...@@ -468,7 +468,7 @@ SECURITY_STATUS WINAPI DeleteSecurityContext(PCtxtHandle phContext)
ret = package->provider->fnTableW.DeleteSecurityContext(ctxt); ret = package->provider->fnTableW.DeleteSecurityContext(ctxt);
else else
ret = SEC_E_INVALID_HANDLE; ret = SEC_E_INVALID_HANDLE;
HeapFree(GetProcessHeap(), 0, ctxt); heap_free(ctxt);
} }
else else
ret = SEC_E_INVALID_HANDLE; ret = SEC_E_INVALID_HANDLE;
...@@ -713,7 +713,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName, ...@@ -713,7 +713,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoA(SEC_CHAR *pszPackageName,
package->infoW.Comment, -1, NULL, 0, NULL, NULL); package->infoW.Comment, -1, NULL, 0, NULL, NULL);
bytesNeeded += commentLen; bytesNeeded += commentLen;
} }
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); *ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo) if (*ppPackageInfo)
{ {
PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo + PSTR nextString = (PSTR)((PBYTE)*ppPackageInfo +
...@@ -775,7 +775,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName, ...@@ -775,7 +775,7 @@ SECURITY_STATUS WINAPI QuerySecurityPackageInfoW(SEC_WCHAR *pszPackageName,
commentLen = lstrlenW(package->infoW.Comment) + 1; commentLen = lstrlenW(package->infoW.Comment) + 1;
bytesNeeded += commentLen * sizeof(WCHAR); bytesNeeded += commentLen * sizeof(WCHAR);
} }
*ppPackageInfo = HeapAlloc(GetProcessHeap(), 0, bytesNeeded); *ppPackageInfo = heap_alloc(bytesNeeded);
if (*ppPackageInfo) if (*ppPackageInfo)
{ {
PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo + PWSTR nextString = (PWSTR)((PBYTE)*ppPackageInfo +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment