From c58aac42664dd1a04edb37b0874109a6a88d0da1 Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Mon, 5 Jun 2017 09:43:46 +0200
Subject: [PATCH 172/181] pam_sss: Fix leaking of memory in case of failures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Found by coverity.
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
(cherry picked from commit 818d01b4a0d332fff06db33c0c985b8c0f1417c7)
---
src/sss_client/pam_sss.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c
index 9732459e6fb7ce01c9445c423cf0a583ca36e036..303809b9ea05b5a8709c05ae230d5f289b57de31 100644
--- a/src/sss_client/pam_sss.c
+++ b/src/sss_client/pam_sss.c
@@ -1517,10 +1517,12 @@ static int prompt_sc_pin(pam_handle_t *pamh, struct pam_items *pi)
if (pi->user_name_hint) {
ret = pam_get_item(pamh, PAM_CONV, (const void **)&conv);
if (ret != PAM_SUCCESS) {
+ free(prompt);
return ret;
}
if (conv == NULL || conv->conv == NULL) {
logger(pamh, LOG_ERR, "No conversation function");
+ free(prompt);
return PAM_SYSTEM_ERR;
}
@@ -1540,6 +1542,7 @@ static int prompt_sc_pin(pam_handle_t *pamh, struct pam_items *pi)
mesg[1] = &((*mesg)[1]);
ret = conv->conv(2, mesg, &resp, conv->appdata_ptr);
+ free(prompt);
if (ret != PAM_SUCCESS) {
D(("Conversation failure: %s.", pam_strerror(pamh, ret)));
return ret;
--
2.9.4