diff options
author | Jan Cholasta <jcholast@redhat.com> | 2014-11-24 13:57:10 +0000 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2014-11-25 08:23:24 +0000 |
commit | d55936756d9593bb1c713dc4c1edd251a112c619 (patch) | |
tree | 7c087a617e2eee5d5d5ed5062add4675778d7457 | |
parent | 66a42e67f337c04fcbf0725ff0d324afe453bf8c (diff) | |
download | freeipa-d55936756d9593bb1c713dc4c1edd251a112c619.tar.gz freeipa-d55936756d9593bb1c713dc4c1edd251a112c619.tar.xz freeipa-d55936756d9593bb1c713dc4c1edd251a112c619.zip |
Fix memory leak in GetKeytabControl asn1 code
https://fedorahosted.org/freeipa/ticket/4713
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
-rw-r--r-- | asn1/ipa_asn1.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/asn1/ipa_asn1.c b/asn1/ipa_asn1.c index 50851a804..9efca964a 100644 --- a/asn1/ipa_asn1.c +++ b/asn1/ipa_asn1.c @@ -77,12 +77,12 @@ bool ipaasn1_enc_getktreply(int kvno, struct keys_container *keys, { GetKeytabControl_t gkctrl = { 0 }; bool ret = false; + KrbKey_t *KK; gkctrl.present = GetKeytabControl_PR_reply; gkctrl.choice.reply.newkvno = kvno; for (int i = 0; i < keys->nkeys; i++) { - KrbKey_t *KK; KK = calloc(1, sizeof(KrbKey_t)); if (!KK) goto done; KK->key.type = keys->ksdata[i].key.enctype; @@ -109,9 +109,18 @@ bool ipaasn1_enc_getktreply(int kvno, struct keys_container *keys, } ret = encode_GetKeytabControl(&gkctrl, buf, len); + KK = NULL; done: ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_GetKeytabControl, &gkctrl); + if (KK) { + free(KK->key.value.buf); + if (KK->salt) { + free(KK->salt->value.buf); + free(KK->salt); + } + free(KK); + } return ret; } |