From 057c3743c98aba7ae20cf44e2309d280600fa30d Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Fri, 16 Jan 2015 10:14:22 +0100 Subject: [PATCH] fixup a memory leak the caller is responsible for freeing the pam_response from conversations --- pam_yubico.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pam_yubico.c b/pam_yubico.c index 48308bd..776e508 100644 --- a/pam_yubico.c +++ b/pam_yubico.c @@ -384,6 +384,7 @@ display_error(pam_handle_t *pamh, const char *message) { } D(("conv returned: '%s'", resp->resp)); + free(resp); return retval; } #endif /* HAVE_CR */ @@ -728,7 +729,7 @@ pam_sm_authenticate (pam_handle_t * pamh, struct pam_conv *conv; const struct pam_message *pmsg[1]; struct pam_message msg[1]; - struct pam_response *resp; + struct pam_response *resp = NULL; int nargs = 1; ykclient_t *ykc = NULL; struct cfg cfg_st; @@ -875,7 +876,6 @@ pam_sm_authenticate (pam_handle_t * pamh, } } msg[0].msg_style = cfg->verbose_otp ? PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF; - resp = NULL; retval = conv->conv (nargs, pmsg, &resp, conv->appdata_ptr); @@ -1016,6 +1016,9 @@ done: DBG (("done. [%s]", pam_strerror (pamh, retval))); pam_set_data (pamh, "yubico_setcred_return", (void*) (intptr_t) retval, NULL); + if (resp) + free (resp); + return retval; }