From 225f17470eed9f44282f435ad1ed64c94d9a2ddf Mon Sep 17 00:00:00 2001 From: "Thomas M. DuBuisson" Date: Tue, 24 Nov 2020 14:52:31 -0800 Subject: pam_unix: fix memory leak on error path * modules/pam_unix/bigcrypt.c (bigcrypt) [HAVE_CRYPT_R]: Do not leak cdata if crypt_r() fails. --- modules/pam_unix/bigcrypt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/pam_unix/bigcrypt.c b/modules/pam_unix/bigcrypt.c index e08e4098..31be2f7b 100644 --- a/modules/pam_unix/bigcrypt.c +++ b/modules/pam_unix/bigcrypt.c @@ -111,6 +111,9 @@ char *bigcrypt(const char *key, const char *salt) #endif if (tmp_ptr == NULL) { free(dec_c2_cryptbuf); +#ifdef HAVE_CRYPT_R + free(cdata); +#endif return NULL; } /* and place in the static area */ @@ -137,6 +140,9 @@ char *bigcrypt(const char *key, const char *salt) if (tmp_ptr == NULL) { _pam_overwrite(dec_c2_cryptbuf); free(dec_c2_cryptbuf); +#ifdef HAVE_CRYPT_R + free(cdata); +#endif return NULL; } -- cgit v1.2.1