|
|
e3ffab |
From 456593766c073ab9ea43052d7bb0fceffbff2221 Mon Sep 17 00:00:00 2001
|
|
|
e3ffab |
From: Jan Cholasta <jcholast@redhat.com>
|
|
|
e3ffab |
Date: Mon, 24 Nov 2014 13:57:10 +0000
|
|
|
e3ffab |
Subject: [PATCH] Fix memory leak in GetKeytabControl asn1 code
|
|
|
e3ffab |
|
|
|
e3ffab |
https://fedorahosted.org/freeipa/ticket/4713
|
|
|
e3ffab |
|
|
|
e3ffab |
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
e3ffab |
---
|
|
|
e3ffab |
asn1/ipa_asn1.c | 11 ++++++++++-
|
|
|
e3ffab |
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
e3ffab |
|
|
|
e3ffab |
diff --git a/asn1/ipa_asn1.c b/asn1/ipa_asn1.c
|
|
|
e3ffab |
index 50851a804f59bdb3fcb9ba832b093860d914452d..9efca964ac340208f478483ecfbb70b32d72181c 100644
|
|
|
e3ffab |
--- a/asn1/ipa_asn1.c
|
|
|
e3ffab |
+++ b/asn1/ipa_asn1.c
|
|
|
e3ffab |
@@ -77,12 +77,12 @@ bool ipaasn1_enc_getktreply(int kvno, struct keys_container *keys,
|
|
|
e3ffab |
{
|
|
|
e3ffab |
GetKeytabControl_t gkctrl = { 0 };
|
|
|
e3ffab |
bool ret = false;
|
|
|
e3ffab |
+ KrbKey_t *KK;
|
|
|
e3ffab |
|
|
|
e3ffab |
gkctrl.present = GetKeytabControl_PR_reply;
|
|
|
e3ffab |
gkctrl.choice.reply.newkvno = kvno;
|
|
|
e3ffab |
|
|
|
e3ffab |
for (int i = 0; i < keys->nkeys; i++) {
|
|
|
e3ffab |
- KrbKey_t *KK;
|
|
|
e3ffab |
KK = calloc(1, sizeof(KrbKey_t));
|
|
|
e3ffab |
if (!KK) goto done;
|
|
|
e3ffab |
KK->key.type = keys->ksdata[i].key.enctype;
|
|
|
e3ffab |
@@ -109,9 +109,18 @@ bool ipaasn1_enc_getktreply(int kvno, struct keys_container *keys,
|
|
|
e3ffab |
}
|
|
|
e3ffab |
|
|
|
e3ffab |
ret = encode_GetKeytabControl(&gkctrl, buf, len);
|
|
|
e3ffab |
+ KK = NULL;
|
|
|
e3ffab |
|
|
|
e3ffab |
done:
|
|
|
e3ffab |
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_GetKeytabControl, &gkctrl);
|
|
|
e3ffab |
+ if (KK) {
|
|
|
e3ffab |
+ free(KK->key.value.buf);
|
|
|
e3ffab |
+ if (KK->salt) {
|
|
|
e3ffab |
+ free(KK->salt->value.buf);
|
|
|
e3ffab |
+ free(KK->salt);
|
|
|
e3ffab |
+ }
|
|
|
e3ffab |
+ free(KK);
|
|
|
e3ffab |
+ }
|
|
|
e3ffab |
return ret;
|
|
|
e3ffab |
}
|
|
|
e3ffab |
|
|
|
e3ffab |
--
|
|
|
e3ffab |
2.1.0
|
|
|
e3ffab |
|