summaryrefslogtreecommitdiffstats
path: root/src/responder/nss
diff options
context:
space:
mode:
authorPavel Reichl <preichl@redhat.com>2014-04-17 16:52:43 +0000
committerJakub Hrozek <jhrozek@redhat.com>2014-06-19 18:04:05 +0200
commitea67da003731c3ac6c37b22568683f29853c8f5c (patch)
tree406a20bdadc5efc0891a2ba03a9105a316231890 /src/responder/nss
parent96d5ff54565f6aaccd09ed4c84b45a712345fcc9 (diff)
downloadsssd-ea67da003731c3ac6c37b22568683f29853c8f5c.tar.gz
sssd-ea67da003731c3ac6c37b22568683f29853c8f5c.tar.xz
sssd-ea67da003731c3ac6c37b22568683f29853c8f5c.zip
NSS: fix memory leak in sysdb_getnetgr
Reviewed-by: Michal Židek <mzidek@redhat.com>
Diffstat (limited to 'src/responder/nss')
-rw-r--r--src/responder/nss/nsssrv_netgroup.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c
index 0f7f782a2..9906dc858 100644
--- a/src/responder/nss/nsssrv_netgroup.c
+++ b/src/responder/nss/nsssrv_netgroup.c
@@ -499,7 +499,8 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
dom->case_sensitive);
if (!name) {
DEBUG(SSSDBG_CRIT_FAILURE, "sss_get_cased_name failed\n");
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
DEBUG(SSSDBG_CONF_SETTINGS, "Requesting info for [%s@%s]\n",
@@ -507,12 +508,12 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
if (dom->sysdb == NULL) {
DEBUG(SSSDBG_FATAL_FAILURE,
"Fatal: Sysdb CTX not found for this domain!\n");
- return EIO;
+ ret = EIO;
+ goto done;
}
/* Look up the netgroup in the cache */
ret = sysdb_getnetgr(step_ctx->dctx, dom, name, &step_ctx->dctx->res);
-
if (ret == ENOENT) {
/* This netgroup was not found in this domain */
if (!step_ctx->dctx->check_provider) {
@@ -528,13 +529,15 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE,
"Failed to make request to our cache!\n");
- return EIO;
+ ret = EIO;
+ goto done;
}
if (step_ctx->dctx->res->count > 1) {
DEBUG(SSSDBG_FATAL_FAILURE,
"getnetgr call returned more than one result !?!\n");
- return EMSGSIZE;
+ ret = EMSGSIZE;
+ goto done;
}
ret = get_netgroup_entry(step_ctx->nctx, step_ctx->name,
@@ -542,7 +545,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
if (ret != EOK) {
/* Something really bad happened! */
DEBUG(SSSDBG_FATAL_FAILURE, "Netgroup entry was lost!\n");
- return ret;
+ goto done;
}
/* Convert the result to a list of entries */
@@ -569,7 +572,8 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
netgr->ready = true;
netgr->found = false;
set_netgr_lifetime(step_ctx->nctx->neg_timeout, step_ctx, netgr);
- return EIO;
+ ret = EIO;
+ goto done;
}
/* if this is a caching provider (or if we haven't checked the cache
@@ -586,7 +590,7 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
/* May return EAGAIN legitimately to indicate that
* we need to reenter the mainloop
*/
- return ret;
+ goto done;
}
}
@@ -603,7 +607,9 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
}
if (lifetime < 10) lifetime = 10;
set_netgr_lifetime(lifetime, step_ctx, netgr);
- return EOK;
+
+ ret = EOK;
+ goto done;
}
/* If we've gotten here, then no domain contained this netgroup */
@@ -619,8 +625,11 @@ static errno_t lookup_netgr_step(struct setent_step_ctx *step_ctx)
"create_negcache_netgr failed with: %d:[%s], ignored.\n",
ret, sss_strerror(ret));
}
+ ret = ENOENT;
- return ENOENT;
+done:
+ talloc_free(name);
+ return ret;
}
static void lookup_netgr_dp_callback(uint16_t err_maj, uint32_t err_min,