* util_crypt.c (kg_encrypt, kg_decrypt): Use free() instead of
krb5_free_data_contents().
* util_cksum.c (kg_checksum_channel_bindings): Make sure that
returned memory is allocated with xmalloc() so that caller can use
xfree() on it.
* k5unseal.c (kg_unseal_v1): Use krb5_free_data_contents()
instead of xfree().
* k5seal.c (make_seal_token_v1): Use krb5_free_data_contents()
instead of xfree().
* init_sec_context.c (make_ap_req_v1): Use xfree() instead of
free() to be consistent with xmalloc() usage. Use
krb5_free_data_contents() instead of xfree().
* disp_name.c (krb5_gss_display_name): Use
krb5_free_unparsed_name() instead of xfree().
* add_cred.c (krb5_gss_add_cred): Use xfree() instead of free() to
be consistent with xmalloc() usage.
* accept_sec_context.c (krb5_gss_accept_sec_context): Remove
variables that were effectively unused. Use
krb5_free_data_contents() instead of xfree() where appropriate.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@13482
dc483132-0cff-0310-8789-
dd5450dbe970
+2001-06-22 Danilo Almeida <dalmeida@mit.edu>
+
+ * util_crypt.c (kg_encrypt, kg_decrypt): Use free() instead of
+ krb5_free_data_contents().
+
+ * util_cksum.c (kg_checksum_channel_bindings): Make sure that
+ returned memory is allocated with xmalloc() so that caller can use
+ xfree() on it.
+
+ * k5unseal.c (kg_unseal_v1): Use krb5_free_data_contents()
+ instead of xfree().
+
+ * k5seal.c (make_seal_token_v1): Use krb5_free_data_contents()
+ instead of xfree().
+
+ * init_sec_context.c (make_ap_req_v1): Use xfree() instead of
+ free() to be consistent with xmalloc() usage. Use
+ krb5_free_data_contents() instead of xfree().
+
+ * disp_name.c (krb5_gss_display_name): Use
+ krb5_free_unparsed_name() instead of xfree().
+
+ * add_cred.c (krb5_gss_add_cred): Use xfree() instead of free() to
+ be consistent with xmalloc() usage.
+
+ * accept_sec_context.c (krb5_gss_accept_sec_context): Remove
+ variables that were effectively unused. Use
+ krb5_free_data_contents() instead of xfree() where appropriate.
+
2001-06-20 Ezra Peisach <epeisach@mit.edu>
* acquire_cred.c (acquire_init_cred): Include "k5-int.h" for
size_t md5len;
int bigend;
krb5_gss_cred_id_t cred = 0;
- krb5_data ap_rep, ap_req, mic;
+ krb5_data ap_rep, ap_req;
int i;
krb5_error_code code;
krb5_address addr, *paddr;
krb5_auth_context auth_context = NULL;
krb5_ticket * ticket = NULL;
int option_id;
- krb5_data option, cksumdata;
+ krb5_data option;
const gss_OID_desc *mech_used = NULL;
OM_uint32 major_status = GSS_S_FAILURE;
krb5_error krb_error_data;
krb5_data scratch;
gss_cred_id_t cred_handle = NULL;
krb5_gss_cred_id_t deleg_cred = NULL;
- krb5_cksumtype *ctypes = 0;
if (GSS_ERROR(kg_get_context(minor_status, &context)))
return(GSS_S_FAILURE);
output_token->value = NULL;
token.value = 0;
reqcksum.contents = 0;
- mic.data = 0;
ap_req.data = 0;
ap_rep.data = 0;
- cksumdata.data = 0;
if (mech_type)
*mech_type = GSS_C_NULL_OID;
major_status = GSS_S_COMPLETE;
fail:
- if (ctypes)
- free(ctypes);
if (authdat)
krb5_free_authenticator(context, authdat);
/* The ctx structure has the handle of the auth_context */
if (reqcksum.contents)
xfree(reqcksum.contents);
if (ap_rep.data)
- xfree(ap_rep.data);
- if (mic.data)
- xfree(mic.data);
- if (cksumdata.data)
- xfree(cksumdata.data);
+ krb5_free_data_contents(context, &ap_rep);
if (!GSS_ERROR(major_status))
return(major_status);
g_make_token_header((gss_OID) mech_used, tmsglen, &ptr, toktype);
TWRITE_STR(ptr, scratch.data, scratch.length);
- xfree(scratch.data);
+ krb5_free_data_contents(context, &scratch);
*output_token = token;
}
code = krb5_copy_principal(context, cred->princ, &new_cred->princ);
if (code) {
- free(new_cred);
+ xfree(new_cred);
*minor_status = code;
return(GSS_S_FAILURE);
kttype = krb5_kt_get_type(context, cred->keytab);
if ((strlen(kttype)+2) > sizeof(ktboth)) {
krb5_free_principal(context, new_cred->princ);
- free(new_cred);
+ xfree(new_cred);
*minor_status = ENOMEM;
return(GSS_S_FAILURE);
sizeof(ktboth)-strlen(ktboth));
if (code) {
krb5_free_principal(context, new_cred->princ);
- free(new_cred);
+ xfree(new_cred);
*minor_status = code;
return(GSS_S_FAILURE);
code = krb5_kt_resolve(context, ktboth, &new_cred->keytab);
if (code) {
krb5_free_principal(context, new_cred->princ);
- free(new_cred);
+ xfree(new_cred);
*minor_status = code;
return(GSS_S_FAILURE);
if (new_cred->keytab)
krb5_kt_close(context, new_cred->keytab);
krb5_free_principal(context, new_cred->princ);
- free(new_cred);
+ xfree(new_cred);
*minor_status = code;
return(GSS_S_FAILURE);
if (new_cred->keytab)
krb5_kt_close(context, new_cred->keytab);
krb5_free_principal(context, new_cred->princ);
- free(new_cred);
+ xfree(new_cred);
*minor_status = ENOMEM;
return(GSS_S_FAILURE);
if (new_cred->keytab)
krb5_kt_close(context, new_cred->keytab);
krb5_free_principal(context, new_cred->princ);
- free(new_cred);
+ xfree(new_cred);
*minor_status = code;
return(GSS_S_FAILURE);
if (new_cred->keytab)
krb5_kt_close(context, new_cred->keytab);
krb5_free_principal(context, new_cred->princ);
- free(new_cred);
+ xfree(new_cred);
*minor_status = (OM_uint32) G_VALIDATE_FAILED;
return(GSS_S_FAILURE);
}
if (! g_make_string_buffer(str, output_name_buffer)) {
- xfree(str);
+ krb5_free_unparsed_name(context, str);
*minor_status = (OM_uint32) G_BUFFER_ALLOC;
return(GSS_S_FAILURE);
}
- xfree(str);
+ krb5_free_unparsed_name(context, str);
*minor_status = 0;
if (output_name_type)
cleanup:
if (checksum_data.data)
- free(checksum_data.data);
+ xfree(checksum_data.data);
if (ap_req.data)
- xfree(ap_req.data);
+ krb5_free_data_contents(context, &ap_req);
return (code);
}
(g_OID_equal(oid, gss_mech_krb5_old) ?
seq->contents : NULL),
md5cksum.contents, md5cksum.contents, 16))) {
- xfree(md5cksum.contents);
+ krb5_free_checksum_contents(context, &md5cksum);
xfree(t);
return code;
}
break;
}
- xfree(md5cksum.contents);
+ krb5_free_checksum_contents(context, &md5cksum);
/* create the seq_num */
(g_OID_equal(ctx->mech_used, gss_mech_krb5_old) ?
ctx->seq->contents : NULL),
md5cksum.contents, md5cksum.contents, 16))) {
- xfree(md5cksum.contents);
+ krb5_free_checksum_contents(context, &md5cksum);
if (toktype == KG_TOK_SEAL_MSG)
xfree(token.value);
*minor_status = code;
case SGN_ALG_MD2_5:
if (!ctx->seed_init &&
(code = kg_make_seed(context, ctx->subkey, ctx->seed))) {
- xfree(md5cksum.contents);
+ krb5_free_checksum_contents(context, &md5cksum);
if (sealalg != 0xffff)
xfree(plain);
if (toktype == KG_TOK_SEAL_MSG)
if (! (data_ptr = (void *)
xmalloc(sizeof(ctx->seed) + 8 +
(ctx->big_endian ? token.length : plainlen)))) {
- xfree(md5cksum.contents);
+ krb5_free_checksum_contents(context, &md5cksum);
if (sealalg == 0)
xfree(plain);
if (toktype == KG_TOK_SEAL_MSG)
plaind.length = 8 + sizeof(ctx->seed) +
(ctx->big_endian ? token.length : plainlen);
plaind.data = data_ptr;
- xfree(md5cksum.contents);
+ krb5_free_checksum_contents(context, &md5cksum);
code = krb5_c_make_checksum(context, md5cksum.checksum_type,
ctx->seq, KG_USAGE_SIGN,
&plaind, &md5cksum);
break;
}
- xfree(md5cksum.contents);
+ krb5_free_checksum_contents(context, &md5cksum);
if (sealalg != 0xffff)
xfree(plain);
int bigend;
{
size_t len;
- char *buf, *ptr;
+ char *buf = 0;
+ char *ptr;
size_t sumlen;
krb5_data plaind;
krb5_error_code code;
+ void *temp;
/* initialize the the cksum */
code = krb5_c_checksum_length(context, CKSUMTYPE_RSA_MD5, &sumlen);
code = krb5_c_make_checksum(context, CKSUMTYPE_RSA_MD5, 0, 0,
&plaind, cksum);
- if (code) {
- xfree(buf);
- return(code);
+ if (code)
+ goto cleanup;
+
+ if ((temp = xmalloc(cksum->length)) == NULL) {
+ krb5_free_checksum_contents(context, cksum);
+ code = ENOMEM;
+ goto cleanup;
}
- /* success */
+ memcpy(temp, cksum->contents, cksum->length);
+ krb5_free_checksum_contents(context, cksum);
+ cksum->contents = (krb5_octet *)temp;
- xfree(buf);
- return(0);
+ /* success */
+ cleanup:
+ if (buf)
+ xfree(buf);
+ return code;
}
code = krb5_c_encrypt(context, key, usage, pivd, &inputd, &outputd);
if (pivd != NULL)
- krb5_free_data_contents(context, pivd);
+ free(pivd->data);
return code;
}
code = krb5_c_decrypt(context, key, usage, pivd, &inputd, &outputd);
if (pivd != NULL)
- krb5_free_data_contents(context, pivd);
+ free(pivd->data);
return code;
}