From 7874fcffcf41c8e12a6046fc117b1f062e93e346 Mon Sep 17 00:00:00 2001 From: Richard Basch Date: Tue, 18 Feb 1997 23:55:39 +0000 Subject: [PATCH] Replace krb5_xfree with appropriate free routine git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9905 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kdc/ChangeLog | 6 ++++++ src/kdc/do_as_req.c | 13 +++++-------- src/kdc/do_tgs_req.c | 3 +-- src/kdc/kdc_preauth.c | 23 +++++++++-------------- src/kdc/kdc_util.c | 2 +- src/kdc/kerberos_v4.c | 3 +-- src/kdc/main.c | 2 +- src/kdc/replay.c | 6 +++--- 8 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/kdc/ChangeLog b/src/kdc/ChangeLog index 7ddfe33a8..a9190212b 100644 --- a/src/kdc/ChangeLog +++ b/src/kdc/ChangeLog @@ -2,6 +2,12 @@ Tue Feb 18 09:56:16 1997 Ezra Peisach * kerberos_v4.c: Remove include of krb4-proto.h +Tue Feb 18 18:51:09 1997 Richard Basch + + * do_as_req.c do_tgs_req.c kdc_preauth.c kdc_util.c main.c + replay.c kerberos_v4.c: + Replace krb5_xfree with appropriate free routine. + Thu Feb 6 00:09:46 1997 Richard Basch * Makefile.in: Remove logger.c target before copying over it. diff --git a/src/kdc/do_as_req.c b/src/kdc/do_as_req.c index cf999fec3..d28a6b69e 100644 --- a/src/kdc/do_as_req.c +++ b/src/kdc/do_as_req.c @@ -321,8 +321,7 @@ krb5_data **response; /* filled in with a response packet */ encrypting_key.enctype = ENCTYPE_DES_CBC_MD5; errcode = krb5_encrypt_tkt_part(kdc_context, &encrypting_key, &ticket_reply); - memset((char *)encrypting_key.contents, 0, encrypting_key.length); - krb5_xfree(encrypting_key.contents); + krb5_free_keyblock_contents(kdc_context, &encrypting_key); encrypting_key.contents = 0; if (errcode) { status = "ENCRYPTING_TICKET"; @@ -397,8 +396,7 @@ krb5_data **response; /* filled in with a response packet */ errcode = krb5_encode_kdc_rep(kdc_context, KRB5_AS_REP, &reply_encpart, &encrypting_key, &reply, response); - memset((char *)encrypting_key.contents, 0, encrypting_key.length); - krb5_xfree(encrypting_key.contents); + krb5_free_keyblock_contents(kdc_context, &encrypting_key); encrypting_key.contents = 0; if (errcode) { @@ -438,10 +436,9 @@ errout: errcode = prepare_error_as(request, errcode, &e_data, response); } - if (encrypting_key.contents) { - memset((char *)encrypting_key.contents, 0, encrypting_key.length); - krb5_xfree(encrypting_key.contents); - } + + krb5_free_keyblock_contents(kdc_context, &encrypting_key); + if (cname) free(cname); if (sname) diff --git a/src/kdc/do_tgs_req.c b/src/kdc/do_tgs_req.c index 0ea2df1cd..f2d7d93f1 100644 --- a/src/kdc/do_tgs_req.c +++ b/src/kdc/do_tgs_req.c @@ -567,8 +567,7 @@ tgt_again: ticket_reply.enc_part.kvno = server_key->key_data_kvno; errcode = krb5_encrypt_tkt_part(kdc_context, &encrypting_key, &ticket_reply); - memset((char *)encrypting_key.contents, 0, encrypting_key.length); - krb5_xfree(encrypting_key.contents); + krb5_free_keyblock_contents(kdc_context, &encrypting_key); if (errcode) { status = "TKT_ENCRYPT"; goto cleanup; diff --git a/src/kdc/kdc_preauth.c b/src/kdc/kdc_preauth.c index 6baaa27d1..f1588d924 100644 --- a/src/kdc/kdc_preauth.c +++ b/src/kdc/kdc_preauth.c @@ -381,9 +381,7 @@ verify_enc_timestamp(context, client, request, enc_tkt_reply, pa) key.enctype = enc_data->enctype; retval = krb5_decrypt_data(context, &key, 0, enc_data, &enc_ts_data); - memset((char *)key.contents, 0, key.length); - krb5_xfree(key.contents); - + krb5_free_keyblock_contents(context, &key); if (retval == 0) break; } @@ -405,14 +403,12 @@ verify_enc_timestamp(context, client, request, enc_tkt_reply, pa) cleanup: if (enc_data) { - if (enc_data->ciphertext.data) - krb5_xfree(enc_data->ciphertext.data); + krb5_free_data_contents(context, &enc_data->ciphertext); free(enc_data); } - if (enc_ts_data.data) - krb5_xfree(enc_ts_data.data); + krb5_free_data_contents(context, &enc_ts_data) if (pa_enc) - krb5_xfree(pa_enc); + free(pa_enc); return retval; } @@ -499,7 +495,7 @@ cleanup: if (entry) krb5_free_etype_info(context, entry); if (salt.data) - krb5_xfree(salt.data); + free(salt.data); return retval; } @@ -920,8 +916,7 @@ sc.sam_challenge_label.length = strlen(sc.sam_challenge_label.data); } cleanup: - memset((char *)encrypting_key.contents, 0, encrypting_key.length); - krb5_xfree(encrypting_key.contents); + krb5_free_keyblock_contents(context, &encrypting_key); return retval; } @@ -983,9 +978,9 @@ verify_sam_response(context, client, request, enc_tkt_reply, pa) setflag(enc_tkt_reply->flags, TKT_FLG_HW_AUTH); cleanup: if (retval) com_err("krb5kdc", retval, "sam verify failure"); - if (sr) krb5_xfree(sr); - if (psr) krb5_xfree(psr); - if (esre) krb5_xfree(esre); + if (sr) free(sr); + if (psr) free(psr); + if (esre) free(esre); return retval; } diff --git a/src/kdc/kdc_util.c b/src/kdc/kdc_util.c index a711a27e8..60670ff8e 100644 --- a/src/kdc/kdc_util.c +++ b/src/kdc/kdc_util.c @@ -69,7 +69,7 @@ krb5_authdata ***output; *retdata[i] = **ptr; if (!(retdata[i]->contents = (krb5_octet *)malloc(retdata[i]->length))) { - krb5_xfree(retdata[i]); + free((char *)retdata[i]); retdata[i] = 0; krb5_free_authdata(kdc_context, retdata); return ENOMEM; diff --git a/src/kdc/kerberos_v4.c b/src/kdc/kerberos_v4.c index 6b889613d..b84175f4a 100644 --- a/src/kdc/kerberos_v4.c +++ b/src/kdc/kerberos_v4.c @@ -323,8 +323,7 @@ int compat_decrypt_key (in5, out4) memcpy(out4, out5.contents, out5.length); retval = 0; } - memset(out5.contents, 0, out5.length); - krb5_xfree(out5.contents); + krb5_free_keyblock_contents(kdc_context, &out5); return(retval); } diff --git a/src/kdc/main.c b/src/kdc/main.c index bc7a2fee1..9fdd415ab 100644 --- a/src/kdc/main.c +++ b/src/kdc/main.c @@ -153,7 +153,7 @@ get_realm_port(ctx, realm, name, defport, service) } } } - krb5_xfree(hostlist); + free(hostlist); } } /* diff --git a/src/kdc/replay.c b/src/kdc/replay.c index 1ec38a35a..cf30c0784 100644 --- a/src/kdc/replay.c +++ b/src/kdc/replay.c @@ -101,7 +101,7 @@ register krb5_data **outpkt; hold = eptr; last->next = eptr->next; eptr = last; - krb5_xfree(hold); + free(hold); } else { /* this isn't it, just move along */ last = eptr; @@ -134,12 +134,12 @@ register krb5_data *outpkt; eptr->timein = timenow; eptr->db_age = db_age; if (krb5_copy_data(kdc_context, inpkt, &eptr->req_packet)) { - krb5_xfree(eptr); + free(eptr); return; } if (krb5_copy_data(kdc_context, outpkt, &eptr->reply_packet)) { krb5_free_data(kdc_context, eptr->req_packet); - krb5_xfree(eptr); + free(eptr); return; } eptr->next = root_ptr.next; -- 2.26.2