From 365ce457b010b29a8841d527269ae156c8621dd7 Mon Sep 17 00:00:00 2001 From: des Date: Thu, 23 Oct 2003 08:27:16 +0000 Subject: Plug a memory leak in the PAM child process. It is of no great consequence as the process is short-lived, and the leak occurs very rarely and always shortly before the process terminates. MFC after: 3 days --- crypto/openssh/auth2-pam-freebsd.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crypto/openssh') diff --git a/crypto/openssh/auth2-pam-freebsd.c b/crypto/openssh/auth2-pam-freebsd.c index a0dd88b..e058981 100644 --- a/crypto/openssh/auth2-pam-freebsd.c +++ b/crypto/openssh/auth2-pam-freebsd.c @@ -132,6 +132,7 @@ pam_thread_conv(int n, if (n <= 0 || n > PAM_MAX_NUM_MSG) return (PAM_CONV_ERR); *resp = xmalloc(n * sizeof **resp); + memset(*resp, 0, n * sizeof **resp); buffer_init(&buffer); for (i = 0; i < n; ++i) { (*resp)[i].resp_retcode = 0; @@ -169,6 +170,13 @@ pam_thread_conv(int n, buffer_free(&buffer); return (PAM_SUCCESS); fail: + for (i = 0; i < n; ++i) { + if ((*resp)[i].resp != NULL) { + memset((*resp)[i].resp, 0, strlen((*resp)[i].resp)); + xfree((*resp)[i].resp); + } + } + memset(*resp, 0, n * sizeof **resp); xfree(*resp); *resp = NULL; buffer_free(&buffer); -- cgit v1.1