* The most we'll return is two pa_data, normally just one.
* We need to make room for the NULL terminator.
*/
- return_pa_data = (krb5_pa_data **) malloc(3 * sizeof(krb5_pa_data *));
+ return_pa_data = malloc(3 * sizeof(krb5_pa_data *));
if (return_pa_data == NULL)
goto cleanup;
return_pa_data[1] = NULL; /* in case of an early trip to cleanup */
return_pa_data[2] = NULL; /* Terminate the list */
- return_pa_data[0] = (krb5_pa_data *) malloc(sizeof(krb5_pa_data));
+ return_pa_data[0] = malloc(sizeof(krb5_pa_data));
if (return_pa_data[0] == NULL)
goto cleanup;
- return_pa_data[1] = (krb5_pa_data *) malloc(sizeof(krb5_pa_data));
+ return_pa_data[1] = malloc(sizeof(krb5_pa_data));
if (return_pa_data[1] == NULL)
goto cleanup;
cleanup:
if (der_req != NULL)
krb5_free_data(context, der_req);
-
- if (out_data != NULL)
- free(out_data);
+ free(out_data);
if (retval) {
if (return_pa_data) {
- if (return_pa_data[0] != NULL)
- free(return_pa_data[0]);
- if (return_pa_data[1] != NULL)
- free(return_pa_data[1]);
+ free(return_pa_data[0]);
+ free(return_pa_data[1]);
free(return_pa_data);
}
if (out_data) {
retval = 0;
cleanup:
- if (dh_data.data != NULL)
- free(dh_data.data);
- if (client_key != NULL)
- free(client_key);
+ free(dh_data.data);
+ free(client_key);
free_krb5_kdc_dh_key_info(&kdc_dh);
free_krb5_pa_pk_as_rep(&kdc_reply);
if (key_pack != NULL) {
free_krb5_reply_key_pack(&key_pack);
- if (cksum.contents != NULL)
- free(cksum.contents);
+ free(cksum.contents);
}
if (key_pack9 != NULL)
free_krb5_reply_key_pack_draft9(&key_pack9);
- if (kdc_hostname != NULL)
- free(kdc_hostname);
+ free(kdc_hostname);
pkiDebug("pkinit_as_rep_parse returning %d (%s)\n",
retval, error_message(retval));
void **request_context)
{
krb5_error_code retval = ENOMEM;
- struct _pkinit_req_context *reqctx = NULL;
- struct _pkinit_context *plgctx = (struct _pkinit_context *)plugin_context;
+ pkinit_req_context reqctx = NULL;
+ pkinit_context plgctx = plugin_context;
*request_context = NULL;
- reqctx = (struct _pkinit_req_context *) malloc(sizeof(*reqctx));
+ reqctx = malloc(sizeof(*reqctx));
if (reqctx == NULL)
return;
memset(reqctx, 0, sizeof(*reqctx));
void *plugin_context,
void *request_context)
{
- struct _pkinit_req_context *reqctx =
- (struct _pkinit_req_context *)request_context;
+ pkinit_req_context reqctx = request_context;
pkiDebug("%s: received reqctx at %p\n", __FUNCTION__, reqctx);
if (reqctx == NULL)
pkinit_client_plugin_init(krb5_context context, void **blob)
{
krb5_error_code retval = ENOMEM;
- struct _pkinit_context *ctx = NULL;
+ pkinit_context ctx = NULL;
- ctx = (struct _pkinit_context *)calloc(1, sizeof(*ctx));
+ ctx = calloc(1, sizeof(*ctx));
if (ctx == NULL)
return ENOMEM;
memset(ctx, 0, sizeof(*ctx));
static void
pkinit_client_plugin_fini(krb5_context context, void *blob)
{
- struct _pkinit_context *ctx = (struct _pkinit_context *)blob;
+ pkinit_context ctx = blob;
if (ctx == NULL || ctx->magic != PKINIT_CTX_MAGIC) {
pkiDebug("pkinit_lib_fini: got bad plgctx (%p)!\n", ctx);
}
static krb5_error_code
handle_gic_opt(krb5_context context,
- struct _pkinit_context *plgctx,
+ pkinit_context plgctx,
const char *attr,
const char *value)
{
const char *value)
{
krb5_error_code retval;
- struct _pkinit_context *plgctx = (struct _pkinit_context *)plugin_context;
+ pkinit_context plgctx = plugin_context;
pkiDebug("(pkinit) received '%s' = '%s'\n", attr, value);
retval = handle_gic_opt(context, plgctx, attr, value);
static int pkinit_oids_refs = 0;
krb5_error_code
-pkinit_init_plg_crypto(pkinit_plg_crypto_context *cryptoctx) {
-
+pkinit_init_plg_crypto(pkinit_plg_crypto_context *cryptoctx)
+{
krb5_error_code retval = ENOMEM;
pkinit_plg_crypto_context ctx = NULL;
/* initialize openssl routines */
openssl_init();
- ctx = (pkinit_plg_crypto_context)malloc(sizeof(*ctx));
+ ctx = malloc(sizeof(*ctx));
if (ctx == NULL)
goto out;
memset(ctx, 0, sizeof(*ctx));
krb5_error_code retval = ENOMEM;
pkinit_identity_crypto_context ctx = NULL;
- ctx = (pkinit_identity_crypto_context)malloc(sizeof(*ctx));
+ ctx = malloc(sizeof(*ctx));
if (ctx == NULL)
goto out;
memset(ctx, 0, sizeof(*ctx));
krb5_error_code
pkinit_init_req_crypto(pkinit_req_crypto_context *cryptoctx)
{
-
krb5_error_code retval = ENOMEM;
pkinit_req_crypto_context ctx = NULL;
- ctx = (pkinit_req_crypto_context)malloc(sizeof(*ctx));
+ ctx = malloc(sizeof(*ctx));
if (ctx == NULL)
goto out;
memset(ctx, 0, sizeof(*ctx));
pkinit_C_UnloadModule(ctx->p11_module);
ctx->p11_module = NULL;
}
- if (ctx->p11_module_name != NULL)
- free(ctx->p11_module_name);
- if (ctx->token_label != NULL)
- free(ctx->token_label);
- if (ctx->cert_id != NULL)
- free(ctx->cert_id);
- if (ctx->cert_label != NULL)
- free(ctx->cert_label);
+ free(ctx->p11_module_name);
+ free(ctx->token_label);
+ free(ctx->cert_id);
+ free(ctx->cert_label);
#endif
}
alg->algorithm = OBJ_nid2obj(NID_sha1);
alg->parameter = NULL;
alg_len = i2d_X509_ALGOR(alg, NULL);
- alg_buf = (unsigned char *)malloc(alg_len);
+ alg_buf = malloc(alg_len);
if (alg_buf == NULL)
goto cleanup2;
goto cleanup2;
ASN1_OCTET_STRING_set(digest, md_data2, (int)md_len2);
digest_len = i2d_ASN1_OCTET_STRING(digest, NULL);
- digest_buf = (unsigned char *)malloc(digest_len);
+ digest_buf = malloc(digest_len);
if (digest_buf == NULL)
goto cleanup2;
digestInfo_len = ASN1_object_size(1, (int)(alg_len + digest_len),
V_ASN1_SEQUENCE);
- y = digestInfo_buf = (unsigned char *)malloc(digestInfo_len);
+ y = digestInfo_buf = malloc(digestInfo_len);
if (digestInfo_buf == NULL)
goto cleanup2;
ASN1_put_object(&y, 1, (int)(alg_len + digest_len), V_ASN1_SEQUENCE,
pkiDebug("failed to der encode pkcs7\n");
goto cleanup2;
}
- if ((p = *signed_data =
- (unsigned char *) malloc((size_t)*signed_data_len)) == NULL)
+ if ((p = *signed_data = malloc(*signed_data_len)) == NULL)
goto cleanup2;
/* DER encode PKCS7 data */
if (id_cryptoctx->pkcs11_method == 1 &&
id_cryptoctx->mech == CKM_RSA_PKCS) {
EVP_MD_CTX_cleanup(&ctx2);
- if (digest_buf != NULL)
- free(digest_buf);
- if (digestInfo_buf != NULL)
- free(digestInfo_buf);
- if (alg_buf != NULL)
- free(alg_buf);
+ free(digest_buf);
+ free(digestInfo_buf);
+ free(alg_buf);
if (digest != NULL)
ASN1_OCTET_STRING_free(digest);
}
cleanup:
if (p7 != NULL)
PKCS7_free(p7);
- if (sig != NULL)
- free(sig);
+ free(sig);
return retval;
}
print_buffer_bin((unsigned char *)authz->data, authz->length,
"/tmp/kdc_ad_initial_verified_cas");
#endif
- *authz_data = (unsigned char *)malloc(authz->length);
+ *authz_data = malloc(authz->length);
if (*authz_data == NULL) {
retval = ENOMEM;
goto cleanup;
}
*out_len = i2d_PKCS7(p7, NULL);
- if (!*out_len || (p = *out = (unsigned char *)malloc(*out_len)) == NULL) {
+ if (!*out_len || (p = *out = malloc(*out_len)) == NULL) {
retval = ENOMEM;
goto cleanup;
}
PKCS7_free(p7);
if (in != NULL)
BIO_free(in);
- if (signed_data != NULL)
- free(signed_data);
- if (enc_data != NULL)
- free(enc_data);
+ free(signed_data);
+ free(enc_data);
if (encerts != NULL)
sk_X509_free(encerts);
PKCS7_free(p7);
if (out != NULL)
BIO_free(out);
- if (tmp_buf != NULL)
- free(tmp_buf);
- if (tmp_buf2 != NULL)
- free(tmp_buf2);
+ free(tmp_buf);
+ free(tmp_buf2);
return retval;
}
size_t keybytes, keylength, offset;
krb5_data random_data;
-
- if ((buf = (unsigned char *) malloc(dh_key_len)) == NULL) {
+ if ((buf = malloc(dh_key_len)) == NULL) {
retval = ENOMEM;
goto cleanup;
}
retval = krb5_c_random_to_key(context, etype, &random_data, key_block);
cleanup:
- if (buf != NULL)
- free(buf);
+ free(buf);
if (retval && key_block->contents != NULL && key_block->length != 0) {
memset(key_block->contents, 0, key_block->length);
key_block->length = 0;
if ((pub_key = BN_to_ASN1_INTEGER(cryptoctx->dh->pub_key, NULL)) == NULL)
goto cleanup;
*dh_pubkey_len = i2d_ASN1_INTEGER(pub_key, NULL);
- if ((buf = *dh_pubkey = (unsigned char *)
- malloc((size_t) *dh_pubkey_len)) == NULL) {
+ if ((buf = *dh_pubkey = malloc(*dh_pubkey_len)) == NULL) {
retval = ENOMEM;
goto cleanup;
}
if (cryptoctx->dh != NULL)
DH_free(cryptoctx->dh);
cryptoctx->dh = NULL;
- if (*dh_params != NULL)
- free(*dh_params);
+ free(*dh_params);
*dh_params = NULL;
- if (*dh_pubkey != NULL)
- free(*dh_pubkey);
+ free(*dh_pubkey);
*dh_pubkey = NULL;
if (pub_key != NULL)
ASN1_INTEGER_free(pub_key);
}
*client_key_len = DH_size(cryptoctx->dh);
- if ((*client_key = (unsigned char *)
- malloc((size_t) *client_key_len)) == NULL) {
+ if ((*client_key = malloc(*client_key_len)) == NULL) {
retval = ENOMEM;
goto cleanup;
}
return retval;
cleanup:
- if (*client_key != NULL)
- free(*client_key);
+ free(*client_key);
*client_key = NULL;
if (pub_key != NULL)
ASN1_INTEGER_free(pub_key);
/* generate DH session key */
*server_key_len = DH_size(dh_server);
- if ((*server_key = (unsigned char *) malloc((size_t)*server_key_len)) == NULL)
+ if ((*server_key = malloc(*server_key_len)) == NULL)
goto cleanup;
DH_compute_key(*server_key, dh->pub_key, dh_server);
if ((pub_key = BN_to_ASN1_INTEGER(dh_server->pub_key, NULL)) == NULL)
goto cleanup;
*dh_pubkey_len = i2d_ASN1_INTEGER(pub_key, NULL);
- if ((p = *dh_pubkey = (unsigned char *) malloc((size_t)*dh_pubkey_len)) == NULL)
+ if ((p = *dh_pubkey = malloc(*dh_pubkey_len)) == NULL)
goto cleanup;
i2d_ASN1_INTEGER(pub_key, &p);
if (pub_key != NULL)
cleanup:
if (dh_server != NULL)
DH_free(dh_server);
- if (*dh_pubkey != NULL)
- free(*dh_pubkey);
- if (*server_key != NULL)
- free(*server_key);
+ free(*dh_pubkey);
+ free(*server_key);
return retval;
}
r = ASN1_object_size(1, bufsize, V_ASN1_SEQUENCE);
- tmp = *buf = (unsigned char *)malloc((size_t) r);
+ tmp = *buf = malloc((size_t) r);
if (tmp == NULL)
goto cleanup;
print_buffer_bin((unsigned char *)td_certifiers->data,
td_certifiers->length, "/tmp/kdc_td_certifiers");
#endif
- typed_data = malloc (2 * sizeof(krb5_typed_data *));
+ typed_data = malloc(2 * sizeof(krb5_typed_data *));
if (typed_data == NULL) {
retval = ENOMEM;
goto cleanup;
print_buffer_bin((unsigned char *)data->data, data->length,
"/tmp/kdc_edata");
#endif
- *out_data = (krb5_data *)malloc(sizeof(krb5_data));
+ *out_data = malloc(sizeof(krb5_data));
(*out_data)->length = data->length;
- (*out_data)->data = (char *)malloc(data->length);
+ (*out_data)->data = malloc(data->length);
memcpy((*out_data)->data, data->data, data->length);
retval = 0;
free_krb5_external_principal_identifier(&krb5_trusted_certifiers);
if (data != NULL) {
- if (data->data != NULL)
- free(data->data);
+ free(data->data);
free(data);
}
- if (td_certifiers != NULL)
- free(td_certifiers);
-
- if (typed_data != NULL)
- free_krb5_typed_data(&typed_data);
+ free(td_certifiers);
+ free_krb5_typed_data(&typed_data);
return retval;
}
if (algId == NULL)
goto cleanup;
algId[3] = NULL;
- algId[0] = (krb5_algorithm_identifier *)malloc(sizeof(krb5_algorithm_identifier));
+ algId[0] = malloc(sizeof(krb5_algorithm_identifier));
if (algId[0] == NULL)
goto cleanup;
- algId[0]->parameters.data = (unsigned char *)malloc(buf2_len);
+ algId[0]->parameters.data = malloc(buf2_len);
if (algId[0]->parameters.data == NULL)
goto cleanup;
memcpy(algId[0]->parameters.data, buf2, buf2_len);
algId[0]->parameters.length = buf2_len;
algId[0]->algorithm = dh_oid;
- algId[1] = (krb5_algorithm_identifier *)malloc(sizeof(krb5_algorithm_identifier));
+ algId[1] = malloc(sizeof(krb5_algorithm_identifier));
if (algId[1] == NULL)
goto cleanup;
- algId[1]->parameters.data = (unsigned char *)malloc(buf3_len);
+ algId[1]->parameters.data = malloc(buf3_len);
if (algId[1]->parameters.data == NULL)
goto cleanup;
memcpy(algId[1]->parameters.data, buf3, buf3_len);
algId[1]->parameters.length = buf3_len;
algId[1]->algorithm = dh_oid;
- algId[2] = (krb5_algorithm_identifier *)malloc(sizeof(krb5_algorithm_identifier));
+ algId[2] = malloc(sizeof(krb5_algorithm_identifier));
if (algId[2] == NULL)
goto cleanup;
- algId[2]->parameters.data = (unsigned char *)malloc(buf1_len);
+ algId[2]->parameters.data = malloc(buf1_len);
if (algId[2]->parameters.data == NULL)
goto cleanup;
memcpy(algId[2]->parameters.data, buf1, buf1_len);
if (algId == NULL)
goto cleanup;
algId[2] = NULL;
- algId[0] = (krb5_algorithm_identifier *)malloc(sizeof(krb5_algorithm_identifier));
+ algId[0] = malloc(sizeof(krb5_algorithm_identifier));
if (algId[0] == NULL)
goto cleanup;
- algId[0]->parameters.data = (unsigned char *)malloc(buf2_len);
+ algId[0]->parameters.data = malloc(buf2_len);
if (algId[0]->parameters.data == NULL)
goto cleanup;
memcpy(algId[0]->parameters.data, buf2, buf2_len);
algId[0]->parameters.length = buf2_len;
algId[0]->algorithm = dh_oid;
- algId[1] = (krb5_algorithm_identifier *)malloc(sizeof(krb5_algorithm_identifier));
+ algId[1] = malloc(sizeof(krb5_algorithm_identifier));
if (algId[1] == NULL)
goto cleanup;
- algId[1]->parameters.data = (unsigned char *)malloc(buf3_len);
+ algId[1]->parameters.data = malloc(buf3_len);
if (algId[1]->parameters.data == NULL)
goto cleanup;
memcpy(algId[1]->parameters.data, buf3, buf3_len);
if (algId == NULL)
goto cleanup;
algId[1] = NULL;
- algId[0] = (krb5_algorithm_identifier *)malloc(sizeof(krb5_algorithm_identifier));
+ algId[0] = malloc(sizeof(krb5_algorithm_identifier));
if (algId[0] == NULL)
goto cleanup;
- algId[0]->parameters.data = (unsigned char *)malloc(buf3_len);
+ algId[0]->parameters.data = malloc(buf3_len);
if (algId[0]->parameters.data == NULL)
goto cleanup;
memcpy(algId[0]->parameters.data, buf3, buf3_len);
print_buffer_bin((unsigned char *)encoded_algId->data,
encoded_algId->length, "/tmp/kdc_td_dh_params");
#endif
- typed_data = malloc (2 * sizeof(krb5_typed_data *));
+ typed_data = malloc(2 * sizeof(krb5_typed_data *));
if (typed_data == NULL) {
retval = ENOMEM;
goto cleanup;
print_buffer_bin((unsigned char *)data->data, data->length,
"/tmp/kdc_edata");
#endif
- *out_data = (krb5_data *)malloc(sizeof(krb5_data));
+ *out_data = malloc(sizeof(krb5_data));
if (*out_data == NULL)
goto cleanup;
(*out_data)->length = data->length;
- (*out_data)->data = (char *)malloc(data->length);
+ (*out_data)->data = malloc(data->length);
if ((*out_data)->data == NULL) {
free(*out_data);
*out_data = NULL;
retval = 0;
cleanup:
- if (buf1 != NULL)
- free(buf1);
- if (buf2 != NULL)
- free(buf2);
- if (buf3 != NULL)
- free(buf3);
+ free(buf1);
+ free(buf2);
+ free(buf3);
if (data != NULL) {
- if (data->data != NULL)
- free(data->data);
+ free(data->data);
free(data);
}
- if (typed_data != NULL)
- free_krb5_typed_data(&typed_data);
- if (encoded_algId != NULL)
- free(encoded_algId);
+ free_krb5_typed_data(&typed_data);
+ free(encoded_algId);
if (algId != NULL) {
while(algId[i] != NULL) {
- if (algId[i]->parameters.data != NULL)
- free(algId[i]->parameters.data);
+ free(algId[i]->parameters.data);
free(algId[i]);
i++;
}
tot_len = ASN1_object_size(1, (int)(orig_len+oid_len), V_ASN1_SEQUENCE);
}
- p = *out = (unsigned char *)malloc(tot_len);
+ p = *out = malloc(tot_len);
if (p == NULL) return -1;
if (is_longhorn_server == 0) {
tot_len = ASN1_object_size(1, (int)(oid_len), V_ASN1_SEQUENCE);
- p = *out = (unsigned char *)malloc(tot_len);
+ p = *out = malloc(tot_len);
if (p == NULL)
return -1;
tot_len = ASN1_object_size(1, (int)(orig_len+oid_len), V_ASN1_SEQUENCE);
- p = *out = (unsigned char *)malloc(tot_len);
+ p = *out = malloc(tot_len);
if (p == NULL) return -1;
ASN1_put_object(&p, 1, (int)(orig_len+oid_len),
asn1_const_Finish(&c);
- *outdata = (unsigned char *)malloc((size_t)Tlen);
+ *outdata = malloc((size_t)Tlen);
if (outdata == NULL) {
retval = ENOMEM;
goto cleanup;
if (asprintf(&prompt, "%.*s PIN%s", (int) sizeof (tip->label),
tip->label, warning) < 0)
return ENOMEM;
- rdat.data = (char *)malloc(tip->ulMaxPinLen + 2);
+ rdat.data = malloc(tip->ulMaxPinLen + 2);
rdat.length = tip->ulMaxPinLen + 1;
kprompt.prompt = prompt;
r = KRB5KDC_ERR_PREAUTH_FAILED;
}
}
- if (rdat.data)
- free(rdat.data);
+ free(rdat.data);
return r;
}
if (cctx->slotid != PK_NOSLOT) {
/* A slot was specified, so that's the only one in the list */
count = 1;
- slotlist = (CK_SLOT_ID_PTR) malloc(sizeof (CK_SLOT_ID));
+ slotlist = malloc(sizeof(CK_SLOT_ID));
slotlist[0] = cctx->slotid;
} else {
if (cctx->p11->C_GetSlotList(TRUE, NULL, &count) != CKR_OK)
return KRB5KDC_ERR_PREAUTH_FAILED;
if (count == 0)
return KRB5KDC_ERR_PREAUTH_FAILED;
- slotlist = (CK_SLOT_ID_PTR) malloc(count * sizeof (CK_SLOT_ID));
+ slotlist = malloc(count * sizeof (CK_SLOT_ID));
if (cctx->p11->C_GetSlotList(TRUE, slotlist, &count) != CKR_OK)
return KRB5KDC_ERR_PREAUTH_FAILED;
}
return KRB5KDC_ERR_PREAUTH_FAILED;
}
pkiDebug("data_len = %d\n", data_len);
- cp = (unsigned char *)malloc((size_t) data_len);
+ cp = malloc((size_t) data_len);
if (cp == NULL)
return ENOMEM;
len = data_len;
* get that. So guess, and if it's too small, re-malloc.
*/
len = PK_SIGLEN_GUESS;
- cp = (unsigned char *)malloc((size_t) len);
+ cp = malloc((size_t) len);
if (cp == NULL)
return ENOMEM;
if (r == CKR_BUFFER_TOO_SMALL || (r == CKR_OK && len >= PK_SIGLEN_GUESS)) {
free(cp);
pkiDebug("C_Sign realloc %d\n", (int) len);
- cp = (unsigned char *)malloc((size_t) len);
+ cp = malloc((size_t) len);
r = id_cryptoctx->p11->C_Sign(id_cryptoctx->session, data,
(CK_ULONG) data_len, cp, &len);
}
}
buf_len = EVP_PKEY_size(pkey);
- buf = (unsigned char *)malloc((size_t) buf_len + 10);
+ buf = malloc((size_t) buf_len + 10);
if (buf == NULL)
goto cleanup;
EVP_VerifyInit(&md_ctx, EVP_sha1());
EVP_SignUpdate(&md_ctx, data, data_len);
*sig_len = EVP_PKEY_size(pkey);
- if ((*sig = (unsigned char *) malloc((size_t) *sig_len)) == NULL)
+ if ((*sig = malloc(*sig_len)) == NULL)
goto cleanup;
EVP_SignFinal(&md_ctx, *sig, sig_len, pkey);
pkiDebug("C_GetMechanismList: %s\n", pkinit_pkcs11_code_to_text(r));
return KRB5KDC_ERR_PREAUTH_FAILED;
}
- mechp = (CK_MECHANISM_TYPE_PTR) malloc(count * sizeof (CK_MECHANISM_TYPE));
+ mechp = malloc(count * sizeof (CK_MECHANISM_TYPE));
if (mechp == NULL)
return ENOMEM;
if ((r = id_cryptoctx->p11->C_GetMechanismList(id_cryptoctx->slotid,
if (cred->key != NULL)
EVP_PKEY_free(cred->key);
#ifndef WITHOUT_PKCS11
- if (cred->cert_id != NULL)
- free(cred->cert_id);
+ free(cred->cert_id);
#endif
free(cred);
}
krb5_cas[sk_size] = NULL;
for (i = 0; i < sk_size; i++) {
- krb5_cas[i] = (krb5_external_principal_identifier *)malloc(sizeof(krb5_external_principal_identifier));
+ krb5_cas[i] = malloc(sizeof(krb5_external_principal_identifier));
x = sk_X509_value(sk, i);
xn = X509_get_subject_name(x);
len = i2d_X509_NAME(xn, NULL);
- if ((p = krb5_cas[i]->subjectName.data = (unsigned char *)malloc((size_t) len)) == NULL)
+ if ((p = krb5_cas[i]->subjectName.data = malloc((size_t) len)) == NULL)
goto cleanup;
i2d_X509_NAME(xn, &p);
krb5_cas[i]->subjectName.length = len;
is->serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(x));
len = i2d_PKCS7_ISSUER_AND_SERIAL(is, NULL);
if ((p = krb5_cas[i]->issuerAndSerialNumber.data =
- (unsigned char *)malloc((size_t) len)) == NULL)
+ malloc((size_t) len)) == NULL)
goto cleanup;
i2d_PKCS7_ISSUER_AND_SERIAL(is, &p);
krb5_cas[i]->issuerAndSerialNumber.length = len;
NULL))) {
len = i2d_ASN1_OCTET_STRING(ikeyid, NULL);
if ((p = krb5_cas[i]->subjectKeyIdentifier.data =
- (unsigned char *)malloc((size_t) len)) == NULL)
+ malloc((size_t) len)) == NULL)
goto cleanup;
i2d_ASN1_OCTET_STRING(ikeyid, &p);
krb5_cas[i]->subjectKeyIdentifier.length = len;
if (loids == NULL)
goto cleanup;
loids[1] = NULL;
- loids[0] = (krb5_algorithm_identifier *)malloc(sizeof(krb5_algorithm_identifier));
+ loids[0] = malloc(sizeof(krb5_algorithm_identifier));
if (loids[0] == NULL) {
free(loids);
goto cleanup;
krb5_cas[sk_size] = NULL;
for (i = 0; i < sk_size; i++) {
- krb5_cas[i] = (krb5_trusted_ca *)malloc(sizeof(krb5_trusted_ca));
+ krb5_cas[i] = malloc(sizeof(krb5_trusted_ca));
if (krb5_cas[i] == NULL)
goto cleanup;
x = sk_X509_value(sk, i);
xn = X509_get_subject_name(x);
len = i2d_X509_NAME(xn, NULL);
if ((p = krb5_cas[i]->u.caName.data =
- (unsigned char *)malloc((size_t) len)) == NULL)
+ malloc((size_t) len)) == NULL)
goto cleanup;
i2d_X509_NAME(xn, &p);
krb5_cas[i]->u.caName.length = len;
is->serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(x));
len = i2d_PKCS7_ISSUER_AND_SERIAL(is, NULL);
if ((p = krb5_cas[i]->u.issuerAndSerial.data =
- (unsigned char *)malloc((size_t) len)) == NULL)
+ malloc((size_t) len)) == NULL)
goto cleanup;
i2d_PKCS7_ISSUER_AND_SERIAL(is, &p);
krb5_cas[i]->u.issuerAndSerial.length = len;
M_ASN1_INTEGER_free(is->serial);
is->serial = M_ASN1_INTEGER_dup(X509_get_serialNumber(cert));
len = i2d_PKCS7_ISSUER_AND_SERIAL(is, NULL);
- if ((p = *out = (unsigned char *)malloc((size_t) len)) == NULL)
+ if ((p = *out = malloc((size_t) len)) == NULL)
goto cleanup;
i2d_PKCS7_ISSUER_AND_SERIAL(is, &p);
*out_len = len;
if ((s = d2i_ASN1_BIT_STRING(NULL, &p, data_len)) == NULL)
goto cleanup;
*out_len = s->length;
- if ((*out = (unsigned char *) malloc((size_t) *out_len + 1)) == NULL) {
+ if ((*out = malloc((size_t) *out_len + 1)) == NULL) {
retval = ENOMEM;
goto cleanup;
}
pkinit_req_opts *opts = NULL;
*reqopts = NULL;
- opts = (pkinit_req_opts *) calloc(1, sizeof(pkinit_req_opts));
+ opts = calloc(1, sizeof(*opts));
if (opts == NULL)
return retval;
void
pkinit_fini_req_opts(pkinit_req_opts *opts)
{
- if (opts != NULL)
- free(opts);
+ free(opts);
return;
}
pkinit_plg_opts *opts = NULL;
*plgopts = NULL;
- opts = (pkinit_plg_opts *) calloc(1, sizeof(pkinit_plg_opts));
+ opts = calloc(1, sizeof(pkinit_plg_opts));
if (opts == NULL)
return retval;
void
pkinit_fini_plg_opts(pkinit_plg_opts *opts)
{
- if (opts != NULL)
- free(opts);
+ free(opts);
return;
}
free_krb5_pa_pk_as_req(krb5_pa_pk_as_req **in)
{
if (*in == NULL) return;
- if ((*in)->signedAuthPack.data != NULL)
- free((*in)->signedAuthPack.data);
+ free((*in)->signedAuthPack.data);
if ((*in)->trustedCertifiers != NULL)
free_krb5_external_principal_identifier(&(*in)->trustedCertifiers);
- if ((*in)->kdcPkId.data != NULL)
- free((*in)->kdcPkId.data);
+ free((*in)->kdcPkId.data);
free(*in);
}
free_krb5_pa_pk_as_req_draft9(krb5_pa_pk_as_req_draft9 **in)
{
if (*in == NULL) return;
- if ((*in)->signedAuthPack.data != NULL)
- free((*in)->signedAuthPack.data);
- if ((*in)->kdcCert.data != NULL)
- free((*in)->kdcCert.data);
- if ((*in)->encryptionCert.data != NULL)
- free((*in)->encryptionCert.data);
+ free((*in)->signedAuthPack.data);
+ free((*in)->kdcCert.data);
+ free((*in)->encryptionCert.data);
if ((*in)->trustedCertifiers != NULL)
free_krb5_trusted_ca(&(*in)->trustedCertifiers);
free(*in);
free_krb5_reply_key_pack(krb5_reply_key_pack **in)
{
if (*in == NULL) return;
- if ((*in)->replyKey.contents != NULL)
- free((*in)->replyKey.contents);
- if ((*in)->asChecksum.contents != NULL)
- free((*in)->asChecksum.contents);
+ free((*in)->replyKey.contents);
+ free((*in)->asChecksum.contents);
free(*in);
}
free_krb5_reply_key_pack_draft9(krb5_reply_key_pack_draft9 **in)
{
if (*in == NULL) return;
- if ((*in)->replyKey.contents != NULL)
- free((*in)->replyKey.contents);
+ free((*in)->replyKey.contents);
free(*in);
}
{
if ((*in) == NULL) return;
if ((*in)->clientPublicValue != NULL) {
- if ((*in)->clientPublicValue->algorithm.algorithm.data != NULL)
- free((*in)->clientPublicValue->algorithm.algorithm.data);
- if ((*in)->clientPublicValue->algorithm.parameters.data != NULL)
- free((*in)->clientPublicValue->algorithm.parameters.data);
- if ((*in)->clientPublicValue->subjectPublicKey.data != NULL)
- free((*in)->clientPublicValue->subjectPublicKey.data);
+ free((*in)->clientPublicValue->algorithm.algorithm.data);
+ free((*in)->clientPublicValue->algorithm.parameters.data);
+ free((*in)->clientPublicValue->subjectPublicKey.data);
free((*in)->clientPublicValue);
}
- if ((*in)->pkAuthenticator.paChecksum.contents != NULL)
- free((*in)->pkAuthenticator.paChecksum.contents);
+ free((*in)->pkAuthenticator.paChecksum.contents);
if ((*in)->supportedCMSTypes != NULL)
free_krb5_algorithm_identifiers(&((*in)->supportedCMSTypes));
free(*in);
if (*in == NULL) return;
switch ((*in)->choice) {
case choice_pa_pk_as_rep_dhInfo:
- if ((*in)->u.dh_Info.dhSignedData.data != NULL)
- free((*in)->u.dh_Info.dhSignedData.data);
+ free((*in)->u.dh_Info.dhSignedData.data);
break;
case choice_pa_pk_as_rep_encKeyPack:
- if ((*in)->u.encKeyPack.data != NULL)
- free((*in)->u.encKeyPack.data);
+ free((*in)->u.encKeyPack.data);
break;
default:
break;
free_krb5_pa_pk_as_rep_draft9(krb5_pa_pk_as_rep_draft9 **in)
{
if (*in == NULL) return;
- if ((*in)->u.encKeyPack.data != NULL)
- free((*in)->u.encKeyPack.data);
+ free((*in)->u.encKeyPack.data);
free(*in);
}
int i = 0;
if (*in == NULL) return;
while ((*in)[i] != NULL) {
- if ((*in)[i]->subjectName.data != NULL)
- free((*in)[i]->subjectName.data);
- if ((*in)[i]->issuerAndSerialNumber.data != NULL)
- free((*in)[i]->issuerAndSerialNumber.data);
- if ((*in)[i]->subjectKeyIdentifier.data != NULL)
- free((*in)[i]->subjectKeyIdentifier.data);
+ free((*in)[i]->subjectName.data);
+ free((*in)[i]->issuerAndSerialNumber.data);
+ free((*in)[i]->subjectKeyIdentifier.data);
free((*in)[i]);
i++;
}
case choice_trusted_cas_principalName:
break;
case choice_trusted_cas_caName:
- if ((*in)[i]->u.caName.data != NULL)
- free((*in)[i]->u.caName.data);
+ free((*in)[i]->u.caName.data);
break;
case choice_trusted_cas_issuerAndSerial:
- if ((*in)[i]->u.issuerAndSerial.data != NULL)
- free((*in)[i]->u.issuerAndSerial.data);
+ free((*in)[i]->u.issuerAndSerial.data);
break;
case choice_trusted_cas_UNKNOWN:
break;
int i = 0;
if (*in == NULL) return;
while ((*in)[i] != NULL) {
- if ((*in)[i]->data != NULL)
- free((*in)[i]->data);
+ free((*in)[i]->data);
free((*in)[i]);
i++;
}
{
if (in == NULL)
return;
- if (in->algorithm.data != NULL)
- free(in->algorithm.data);
- if (in->parameters.data != NULL)
- free(in->parameters.data);
+ free(in->algorithm.data);
+ free(in->parameters.data);
free(in);
}
free_krb5_subject_pk_info(krb5_subject_pk_info **in)
{
if ((*in) == NULL) return;
- if ((*in)->algorithm.parameters.data != NULL)
- free((*in)->algorithm.parameters.data);
- if ((*in)->subjectPublicKey.data != NULL)
- free((*in)->subjectPublicKey.data);
+ free((*in)->algorithm.parameters.data);
+ free((*in)->subjectPublicKey.data);
free(*in);
}
free_krb5_kdc_dh_key_info(krb5_kdc_dh_key_info **in)
{
if (*in == NULL) return;
- if ((*in)->subjectPublicKey.data != NULL)
- free((*in)->subjectPublicKey.data);
+ free((*in)->subjectPublicKey.data);
free(*in);
}