summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-12-19 08:48:06 -0500
committerJakub Hrozek <jhrozek@redhat.com>2012-12-19 18:38:17 +0100
commit529beaac44adaa7af72f372736e7b33417d920d8 (patch)
treebe2b498eaaf01413d31b418a7a456b415dc60257 /src/responder
parent85da72d5b2730c0f7300c15ed17e672026987e44 (diff)
downloadsssd-529beaac44adaa7af72f372736e7b33417d920d8.tar.gz
sssd-529beaac44adaa7af72f372736e7b33417d920d8.tar.xz
sssd-529beaac44adaa7af72f372736e7b33417d920d8.zip
sssd_nss: Plug memory leaks
A recent patch introduced a glaring memory leak in the routines that clean up memcache memory on initgroups calls.
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/nss/nsssrv_cmd.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index e16f90014..ae6a0966e 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);
}
}
@@ -1855,6 +1857,7 @@ void nss_update_gr_memcache(struct nss_ctx *nctx)
ret, strerror(ret)));
}
}
+ talloc_zfree(res);
}
}
@@ -3370,6 +3373,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;
@@ -3395,12 +3399,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
@@ -3455,6 +3461,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 ? */