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,
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)
......
......@@ -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);
}
}
}
......
......@@ -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;
}
......
......@@ -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();
}
......
......@@ -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,
......
......@@ -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;
}
......
......@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <limits.h>
#include "wine/heap.h"
#include "wine/list.h"
#include "schannel.h"
......
......@@ -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;
}
......@@ -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);
}
......@@ -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 +
......
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