krb5_auth_con_init(krb5_context context, krb5_auth_context *auth_context)
{
*auth_context =
- (krb5_auth_context)malloc(sizeof(struct _krb5_auth_context));
+ (krb5_auth_context)calloc(1, sizeof(struct _krb5_auth_context));
if (!*auth_context)
- return ENOMEM;
-
- memset(*auth_context, 0, sizeof(struct _krb5_auth_context));
+ return ENOMEM;
/* Default flags, do time not seq */
(*auth_context)->auth_context_flags =
if ((ret = krb5_c_block_size(context, auth_context->keyblock->enctype,
&blocksize)))
return(ret);
- if ((auth_context->i_vector = (krb5_pointer)malloc(blocksize))) {
- memset(auth_context->i_vector, 0, blocksize);
+ if ((auth_context->i_vector = (krb5_pointer)calloc(1,blocksize))) {
return 0;
}
return ENOMEM;
krb5_error_code retval;
krb5_data *pdata;
- if ((*ppcreds = (krb5_creds *)malloc(sizeof(krb5_creds))) == NULL) {
+ if ((*ppcreds = (krb5_creds *)calloc(1,sizeof(krb5_creds))) == NULL) {
return ENOMEM;
}
- memset(*ppcreds, 0, sizeof(krb5_creds));
-
if ((retval = krb5_copy_principal(context, pkdcrep->client,
&(*ppcreds)->client)))
goto cleanup;
*context = 0;
- ctx = malloc(sizeof(struct _krb5_context));
+ ctx = calloc(1, sizeof(struct _krb5_context));
if (!ctx)
return ENOMEM;
- memset(ctx, 0, sizeof(struct _krb5_context));
ctx->magic = KV5M_CONTEXT;
ctx->profile_secure = secure;
/* Get memory for creds and initialize it */
size = sizeof(krb5_cred_info *) * (nppcreds + 1);
- credenc.ticket_info = (krb5_cred_info **) malloc(size);
+ credenc.ticket_info = (krb5_cred_info **) calloc(1, size);
if (credenc.ticket_info == NULL)
return ENOMEM;
- memset(credenc.ticket_info, 0, size);
-
+
/*
* For each credential in the list, initialize a cred info
* structure and copy the ticket into the ticket list.
*/
for (ncred = 0; ppcreds[ncred]; ncred++);
- if ((pcred = (krb5_cred *)malloc(sizeof(krb5_cred))) == NULL)
+ if ((pcred = (krb5_cred *)calloc(1, sizeof(krb5_cred))) == NULL)
return ENOMEM;
- memset(pcred, 0, sizeof(krb5_cred));
if ((pcred->tickets
- = (krb5_ticket **)malloc(sizeof(krb5_ticket *) * (ncred + 1))) == NULL) {
+ = (krb5_ticket **)calloc(ncred+1, sizeof(krb5_ticket *))) == NULL) {
free(pcred);
return ENOMEM;
}
- memset(pcred->tickets, 0, sizeof(krb5_ticket *) * (ncred +1));
/* Get keyblock */
if ((keyblock = auth_context->send_subkey) == NULL)
alg_ids++) {
num_types++;
}
- *cms_types = kalg_ids = (krb5int_algorithm_id *)malloc(
- sizeof(krb5int_algorithm_id) * num_types);
+ *cms_types = kalg_ids = (krb5int_algorithm_id *)calloc(num_types,
+ sizeof(krb5int_algorithm_id));
*num_cms_types = num_types;
- memset(kalg_ids, 0, sizeof(krb5int_algorithm_id) * num_types);
alg_ids = localAuthPack.supportedCMSTypes;
for(dex=0; dex<num_types; dex++) {
if(alg_ids[dex]->algorithm.Data) {
/*
- * Copyright 1995, 2003 by the Massachusetts Institute of Technology. All
+ * Copyright 1995, 2003, 2008 by the Massachusetts Institute of Technology. All
* Rights Reserved.
*
* Export of this software from the United States of America may
krb5int_free_plugin_dir_data(tables);
return;
}
- context->modules = malloc(sizeof(context->modules[0]) * n_modules);
+ context->modules = calloc(n_modules, sizeof(context->modules[0]));
if (context->modules == NULL) {
krb5int_free_plugin_dir_data(tables);
free(context);
return;
}
- memset(context->modules, 0, sizeof(context->modules[0]) * n_modules);
context->n_modules = n_modules;
/* fill in the structure */
krb5_creds * pcur;
krb5_data * pdata;
- if ((pcur = (krb5_creds *)malloc(sizeof(krb5_creds))) == NULL) {
+ if ((pcur = (krb5_creds *)calloc(1, sizeof(krb5_creds))) == NULL) {
retval = ENOMEM;
goto cleanup;
}
(*pppcreds)[i] = pcur;
(*pppcreds)[i+1] = 0;
pinfo = encpart.ticket_info[i++];
- memset(pcur, 0, sizeof(krb5_creds));
if ((retval = krb5_copy_principal(context, pinfo->client,
&pcur->client)))
/*
* lib/krb5/krb/ser_actx.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
/* Get memory for the auth_context */
if ((remain >= (5*sizeof(krb5_int32))) &&
(auth_context = (krb5_auth_context)
- malloc(sizeof(struct _krb5_auth_context)))) {
- memset(auth_context, 0, sizeof(struct _krb5_auth_context));
+ calloc(1, sizeof(struct _krb5_auth_context)))) {
/* Get auth_context_flags */
(void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
/*
* lib/krb5/krb/ser_adata.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
/* Get a authdata */
if ((remain >= (2*sizeof(krb5_int32))) &&
- (authdata = (krb5_authdata *) malloc(sizeof(krb5_authdata)))) {
- memset(authdata, 0, sizeof(krb5_authdata));
+ (authdata = (krb5_authdata *) calloc(1, sizeof(krb5_authdata)))) {
/* Get the ad_type */
(void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
/*
* lib/krb5/krb/ser_addr.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
/* Get a address */
if ((remain >= (2*sizeof(krb5_int32))) &&
- (address = (krb5_address *) malloc(sizeof(krb5_address)))) {
- memset(address, 0, sizeof(krb5_address));
+ (address = (krb5_address *) calloc(1, sizeof(krb5_address)))) {
address->magic = KV5M_ADDRESS;
/*
* lib/krb5/krb/ser_auth.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
/* Get memory for the authenticator */
if ((remain >= (3*sizeof(krb5_int32))) &&
(authenticator = (krb5_authenticator *)
- malloc(sizeof(krb5_authenticator)))) {
- memset(authenticator, 0, sizeof(krb5_authenticator));
+ calloc(1, sizeof(krb5_authenticator)))) {
/* Get ctime */
(void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
/* Get memory for the authorization data pointers */
if ((authenticator->authorization_data = (krb5_authdata **)
- malloc(sizeof(krb5_authdata *) * len))) {
- memset(authenticator->authorization_data, 0,
- sizeof(krb5_authdata *) * len);
-
+ calloc(len, sizeof(krb5_authdata *)))) {
for (i=0; !kret && (i<nadata); i++) {
kret = krb5_internalize_opaque(kcontext,
KV5M_AUTHDATA,
/*
* lib/krb5/krb/ser_cksum.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
/* Get a checksum */
if ((remain >= (2*sizeof(krb5_int32))) &&
- (checksum = (krb5_checksum *) malloc(sizeof(krb5_checksum)))) {
- memset(checksum, 0, sizeof(krb5_checksum));
-
+ (checksum = (krb5_checksum *) calloc(1, sizeof(krb5_checksum)))) {
/* Get the checksum_type */
(void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
checksum->checksum_type = (krb5_cksumtype) ibuf;
return (EINVAL);
/* Get memory for the context */
- context = (krb5_context) malloc(sizeof(struct _krb5_context));
+ context = (krb5_context) calloc(1, sizeof(struct _krb5_context));
if (!context)
return (ENOMEM);
- memset(context, 0, sizeof(struct _krb5_context));
/* Get the size of the default realm */
if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
goto cleanup;
context->in_tkt_ktype_count = (int) ibuf;
- context->in_tkt_ktypes = (krb5_enctype *) malloc(sizeof(krb5_enctype) *
- (context->in_tkt_ktype_count+1));
+ context->in_tkt_ktypes = (krb5_enctype *) calloc(context->in_tkt_ktype_count+1,
+ sizeof(krb5_enctype));
if (!context->in_tkt_ktypes) {
kret = ENOMEM;
goto cleanup;
}
- memset(context->in_tkt_ktypes, 0, (sizeof(krb5_enctype) *
- (context->in_tkt_ktype_count + 1)));
-
+
for (i=0; i<context->in_tkt_ktype_count; i++) {
if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
goto cleanup;
goto cleanup;
context->tgs_ktype_count = (int) ibuf;
- context->tgs_ktypes = (krb5_enctype *) malloc(sizeof(krb5_enctype) *
- (context->tgs_ktype_count+1));
+ context->tgs_ktypes = (krb5_enctype *) calloc(context->tgs_ktype_count+1,
+ sizeof(krb5_enctype));
if (!context->tgs_ktypes) {
kret = ENOMEM;
goto cleanup;
}
- memset(context->tgs_ktypes, 0, (sizeof(krb5_enctype) *
- (context->tgs_ktype_count + 1)));
for (i=0; i<context->tgs_ktype_count; i++) {
if ((kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain)))
goto cleanup;
/* Get memory for the context */
if ((os_ctx = (krb5_os_context)
- malloc(sizeof(struct _krb5_os_context))) &&
+ calloc(1, sizeof(struct _krb5_os_context))) &&
(remain >= 4*sizeof(krb5_int32))) {
- memset(os_ctx, 0, sizeof(struct _krb5_os_context));
os_ctx->magic = KV5M_OS_CONTEXT;
/* Read out our context */
/*
* lib/krb5/krb/ser_eblk.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
/* Get an encrypt_block */
if ((remain >= (3*sizeof(krb5_int32))) &&
(encrypt_block = (krb5_encrypt_block *)
- malloc(sizeof(krb5_encrypt_block)))) {
- memset(encrypt_block, 0, sizeof(krb5_encrypt_block));
-
+ calloc(1, sizeof(krb5_encrypt_block)))) {
/* Get the enctype */
(void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
ktype = (krb5_enctype) ibuf;
/*
* lib/krb5/krb/ser_key.c
*
- * Copyright 1995 by the Massachusetts Institute of Technology.
+ * Copyright 1995, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
/* Get a keyblock */
if ((remain >= (3*sizeof(krb5_int32))) &&
- (keyblock = (krb5_keyblock *) malloc(sizeof(krb5_keyblock)))) {
- memset(keyblock, 0, sizeof(krb5_keyblock));
-
+ (keyblock = (krb5_keyblock *) calloc(1, sizeof(krb5_keyblock)))) {
/* Get the enctype */
(void) krb5_ser_unpack_int32(&ibuf, &bp, &remain);
keyblock->enctype = (krb5_enctype) ibuf;
continue;
}
#endif
- nw = malloc (sizeof (struct linux_ipv6_addr_list));
+ nw = calloc (1, sizeof (struct linux_ipv6_addr_list));
if (nw == 0)
continue;
- memset (nw, 0, sizeof (*nw));
nw->addr.sin6_addr = a6;
nw->addr.sin6_family = AF_INET6;
/* Ignore other fields, we don't actually use them here. */
for (count = 0; hostrec->h_addr_list[count]; count++);
- paddr = (krb5_address **)malloc(sizeof(krb5_address *) * (count+1));
+ paddr = (krb5_address **)calloc(count+1, sizeof(krb5_address *));
if (!paddr) {
err = ENOMEM;
goto cleanup;
}
- memset(paddr, 0, sizeof(krb5_address *) * (count+1));
-
- for (i = 0; i < count; i++)
- {
+ for (i = 0; i < count; i++) {
paddr[i] = (krb5_address *)malloc(sizeof(krb5_address));
if (paddr[i] == NULL) {
err = ENOMEM;
#endif
)
return 0;
- x = malloc (sizeof (*x));
+ x = calloc (1, sizeof (*x));
if (x == 0) {
d->out_of_mem = 1;
return 1;
}
- memset(x, 0, sizeof (*x));
x->ai.ai_addr = (struct sockaddr *) &x->u;
x->ai.ai_socktype = socktype;
x->ai.ai_family = sa->sa_family;
reply->length = 0;
n_conns = addrs->naddrs;
- conns = malloc(n_conns * sizeof(struct conn_state));
+ conns = calloc(n_conns, sizeof(struct conn_state));
if (conns == NULL) {
return ENOMEM;
}
- memset(conns, 0, n_conns * sizeof(struct conn_state));
-
if (callback_info) {
- callback_data = malloc(n_conns * sizeof(krb5_data));
+ callback_data = calloc(n_conns, sizeof(krb5_data));
if (callback_data == NULL) {
return ENOMEM;
}
-
- memset(callback_data, 0, n_conns * sizeof(krb5_data));
}
for (i = 0; i < n_conns; i++) {
krb5_error_code retval;
/* allocate id? no */
- if (!(t = (struct dfl_data *) malloc(sizeof(struct dfl_data))))
+ if (!(t = (struct dfl_data *) calloc(1, sizeof(struct dfl_data))))
return KRB5_RC_MALLOC;
id->data = (krb5_pointer) t;
- memset(t, 0, sizeof(struct dfl_data));
if (name) {
t->name = malloc(strlen(name)+1);
if (!t->name) {