I introduced a memory leak with the memory cache checks on initgroups. Oh the joy oh the sadness.
Patch attached. Simo. -- Simo Sorce * Red Hat, Inc * New York
>From 69f9660d680f42715c0478012235e88d778d6c9a Mon Sep 17 00:00:00 2001 From: Simo Sorce <[email protected]> Date: Wed, 19 Dec 2012 08:48:06 -0500 Subject: [PATCH] sssd_nss: Plug memory leaks A recent patch introduced a glaring memory leak in the routines that clean up memcache memory on initgroups calls. --- src/responder/nss/nsssrv_cmd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 1215f78d76dfbe22f09f1b21cb9a980a7b4c1ded..31f39dde9ace5fa9d360370cfd45579b3dc420ec 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -154,6 +154,8 @@ void nss_update_pw_memcache(struct nss_ctx *nctx) ret, strerror(ret))); } } + + talloc_zfree(res); } } @@ -1869,6 +1871,7 @@ void nss_update_gr_memcache(struct nss_ctx *nctx) ret, strerror(ret))); } } + talloc_zfree(res); } } @@ -3402,6 +3405,7 @@ void nss_update_initgr_memcache(struct nss_ctx *nctx, const char *name, const char *domain, int gnum, uint32_t *groups) { + TALLOC_CTX *tmp_ctx = NULL; struct sss_domain_info *dom; struct ldb_result *res; bool changed = false; @@ -3427,12 +3431,14 @@ void nss_update_initgr_memcache(struct nss_ctx *nctx, return; } - ret = sysdb_initgroups(NULL, dom->sysdb, name, &res); + tmp_ctx = talloc_new(NULL); + + ret = sysdb_initgroups(tmp_ctx, dom->sysdb, name, &res); if (ret != EOK && ret != ENOENT) { DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to make request to our cache! [%d][%s]\n", ret, strerror(ret))); - return; + goto done; } /* copy, we need the original intact in case we need to invalidate @@ -3487,6 +3493,9 @@ void nss_update_initgr_memcache(struct nss_ctx *nctx, } } } + +done: + talloc_free(tmp_ctx); } /* FIXME: what about mpg, should we return the user's GID ? */ -- 1.8.0.1
_______________________________________________ sssd-devel mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
