From e75fdb3f6f98fc112637bd9dc2c802508dc7984b Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Fri, 30 Apr 2004 02:05:03 +0000 Subject: [PATCH] Add test for EVP_MD_CTX_cleanup() and conditionally compile it in src/common/slurm_cred.c. There is a memory leak without this, but it is missing from some versions of SSL. --- acinclude.m4 | 6 ++++++ src/common/slurm_cred.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 02cfbc06285..21afa1efd4f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -503,6 +503,12 @@ if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; fi fi fi + +AC_TRY_LINK([#include <openssl/evp.h>], + [EVP_MD_CTX_cleanup(NULL);], + [AC_DEFINE(HAVE_EVP_MD_CTX_CLEANUP, 1, + [Define to 1 if function EVP_MD_CTX_cleanup exists.])]) + LIBS="$saved_LIBS" CPPFLAGS="$saved_CPPFLAGS" LDFLAGS="$saved_LDFLAGS" diff --git a/src/common/slurm_cred.c b/src/common/slurm_cred.c index a9901160ba7..97571a276fc 100644 --- a/src/common/slurm_cred.c +++ b/src/common/slurm_cred.c @@ -975,7 +975,10 @@ _slurm_cred_sign(slurm_cred_ctx_t ctx, slurm_cred_t cred) rc = SLURM_ERROR; } +#ifdef HAVE_EVP_MD_CTX_CLEANUP + /* Note: Likely memory leak if this function is absent */ EVP_MD_CTX_cleanup(&ectx); +#endif free_buf(buffer); return rc; -- GitLab