From: John Kohl Date: Thu, 21 Feb 1991 16:37:42 +0000 (+0000) Subject: plug memory leaks X-Git-Tag: krb5-1.0-alpha4~210 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=dc9380fb4c30269a6a44690349fd62c64ab7f8a6;p=krb5.git plug memory leaks git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1762 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kdc/do_as_req.c b/src/kdc/do_as_req.c index a5d59b428..7784c1ff5 100644 --- a/src/kdc/do_as_req.c +++ b/src/kdc/do_as_req.c @@ -153,11 +153,7 @@ krb5_data **response; /* filled in with a response packet */ #undef cleanup #define cleanup() {krb5_db_free_principal(&client, 1); \ krb5_db_free_principal(&server, 1); \ - memset((char *)session_key->contents, 0, \ - session_key->length); \ - xfree(session_key->contents); \ - session_key->contents = 0; } - + krb5_free_keyblock(session_key); } ticket_reply.server = request->server; ticket_reply.enc_part.etype = useetype; @@ -261,10 +257,7 @@ krb5_data **response; /* filled in with a response packet */ #undef cleanup #define cleanup() {krb5_db_free_principal(&client, 1); \ - memset((char *)session_key->contents, 0, \ - session_key->length); \ - xfree(session_key->contents); \ - session_key->contents = 0; \ + krb5_free_keyblock(session_key); \ memset(ticket_reply.enc_part.ciphertext.data, 0, \ ticket_reply.enc_part.ciphertext.length); \ free(ticket_reply.enc_part.ciphertext.data);} @@ -312,10 +305,7 @@ krb5_data **response; /* filled in with a response packet */ #undef cleanup #define cleanup() {krb5_db_free_principal(&client, 1); \ - memset((char *)session_key->contents, 0, \ - session_key->length); \ - xfree(session_key->contents); \ - session_key->contents = 0; \ + krb5_free_keyblock(session_key); \ memset(ticket_reply.enc_part.ciphertext.data, 0, \ ticket_reply.enc_part.ciphertext.length); \ free(ticket_reply.enc_part.ciphertext.data); \ diff --git a/src/kdc/do_tgs_req.c b/src/kdc/do_tgs_req.c index 66d3b91fc..c46a400ee 100644 --- a/src/kdc/do_tgs_req.c +++ b/src/kdc/do_tgs_req.c @@ -182,10 +182,7 @@ tgt_again: #undef cleanup #define cleanup() { krb5_db_free_principal(&server, 1); \ - memset((char *)session_key->contents, 0, \ - session_key->length); \ - xfree(session_key->contents); \ - session_key->contents = 0; } + krb5_free_keyblock(session_key);} ticket_reply.server = request->server; /* XXX careful for realm... */ ticket_reply.enc_part.etype = useetype; @@ -448,10 +445,7 @@ tgt_again: } #undef cleanup #define cleanup() { krb5_db_free_principal(&server, 1); \ - memset((char *)session_key->contents, 0, \ - session_key->length); \ - xfree(session_key->contents); \ - session_key->contents = 0; \ + krb5_free_keyblock(session_key); \ if (newtransited) free(enc_tkt_reply.transited.tr_contents.data);} ticket_reply.enc_part2 = &enc_tkt_reply; @@ -524,10 +518,8 @@ tgt_again: retval = krb5_encode_kdc_rep(KRB5_TGS_REP, &reply_encpart, header_ticket->enc_part2->session, &reply, response); - memset((char *)session_key->contents, 0, session_key->length); - xfree(session_key->contents); + krb5_free_keyblock(session_key); tkt_cleanup(); - session_key->contents = 0; memset(ticket_reply.enc_part.ciphertext.data, 0, ticket_reply.enc_part.ciphertext.length); free(ticket_reply.enc_part.ciphertext.data);