From 0b05bda40a5ee74fb686f41d0c6adc3b0b45ab63 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Fri, 26 Sep 2003 22:43:23 +0000 Subject: [PATCH] Plug some possible memory leaks on various error conditions. --- src/plugins/auth/auth_munge.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/plugins/auth/auth_munge.c b/src/plugins/auth/auth_munge.c index 15808719358..32ac29ec22b 100644 --- a/src/plugins/auth/auth_munge.c +++ b/src/plugins/auth/auth_munge.c @@ -149,6 +149,11 @@ slurm_auth_create( void *argv[] ) munge_ctx_t ctx = munge_ctx_create(); SigFunc *ohandler; + if (ctx == NULL) { + error("munge_ctx_create failure"); + return NULL; + } + cred = xmalloc(sizeof(*cred)); cred->verified = false; cred->m_str = NULL; @@ -434,13 +439,21 @@ _decode_cred(char *m, slurm_auth_credential_t *c) int retry = 2; sigset_t set, oset; munge_err_t e; - munge_ctx_t ctx = munge_ctx_create(); + munge_ctx_t ctx; if ((c == NULL) || (m == NULL)) return SLURM_ERROR; xassert(c->magic == MUNGE_MAGIC); + if (c->verified) + return SLURM_SUCCESS; + + if ((ctx = munge_ctx_create()) == NULL) { + error("munge_ctx_create failure"); + return SLURM_ERROR; + } + /* * Block all signals to allow munge_decode() to proceed * uninterrupted. (Testing for gnats slurm/223) @@ -452,9 +465,6 @@ _decode_cred(char *m, slurm_auth_credential_t *c) if (pthread_sigmask(SIG_SETMASK, &set, &oset) < 0) error("pthread_sigmask: %m"); - if (c->verified) - return SLURM_SUCCESS; - again: if ((e = munge_decode(m, ctx, &c->buf, &c->len, &c->uid, &c->gid))) { error ("Munge decode failed: %s %s", @@ -537,7 +547,7 @@ cred_info_create(munge_ctx_t ctx) e = munge_ctx_get(ctx, MUNGE_OPT_ZIP_TYPE, &mi->zip); if (e != EMUNGE_SUCCESS) - error ("auth_munge: Unable to retrieve mac type: %s", + error ("auth_munge: Unable to retrieve zip type: %s", munge_ctx_strerror(ctx)); return mi; -- GitLab