File 140417-NSS-fix-memory-leak-in-sysdb_getnetgr.patch of Package sssd.5306
From af0834223167694bdec7964c451d174213fba1e1 Mon Sep 17 00:00:00 2001
From: Pavel Reichl <preichl@redhat.com>
Date: Thu, 17 Apr 2014 16:52:43 +0000
Subject: [PATCH] NSS: fix memory leak in sysdb_getnetgr
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Michal Židek <mzidek@redhat.com>
(cherry picked from commit ea67da003731c3ac6c37b22568683f29853c8f5c)
diff -rupN sssd-1.11.5.1-original/src/responder/nss/nsssrv_netgroup.c sssd-1.11.5.1-patched/src/responder/nss/nsssrv_netgroup.c
--- sssd-1.11.5.1-original/src/responder/nss/nsssrv_netgroup.c 2017-01-30 13:33:25.915499052 +0100
+++ sssd-1.11.5.1-patched/src/responder/nss/nsssrv_netgroup.c 2017-01-30 13:38:29.038933781 +0100
@@ -456,7 +456,8 @@ static errno_t lookup_netgr_step(struct
dom->case_sensitive);
if (!name) {
DEBUG(SSSDBG_CRIT_FAILURE, ("sss_get_cased_name failed\n"));
- return ENOMEM;
+ ret = ENOMEM;
+ goto done;
}
DEBUG(4, ("Requesting info for [%s@%s]\n",
@@ -464,7 +465,8 @@ static errno_t lookup_netgr_step(struct
sysdb = dom->sysdb;
if (sysdb == NULL) {
DEBUG(0, ("Fatal: Sysdb CTX not found for this domain!\n"));
- return EIO;
+ ret = EIO;
+ goto done;
}
/* Look up the netgroup in the cache */
@@ -473,7 +475,8 @@ static errno_t lookup_netgr_step(struct
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;
}
if (ret == ENOENT) {
/* This netgroup was not found in this domain */
@@ -489,7 +492,8 @@ static errno_t lookup_netgr_step(struct
if (ret != EOK) {
DEBUG(1, ("Failed to make request to our cache!\n"));
- return EIO;
+ ret = EIO;
+ goto done;
}
ret = get_netgroup_entry(step_ctx->nctx, step_ctx->name,
@@ -497,7 +501,7 @@ static errno_t lookup_netgr_step(struct
if (ret != EOK) {
/* Something really bad happened! */
DEBUG(0, ("Netgroup entry was lost!\n"));
- return ret;
+ goto done;
}
/* Convert the result to a list of entries */
@@ -523,7 +527,8 @@ static errno_t lookup_netgr_step(struct
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
@@ -540,7 +545,7 @@ static errno_t lookup_netgr_step(struct
/* May return EAGAIN legitimately to indicate that
* we need to reenter the mainloop
*/
- return ret;
+ goto done;
}
}
@@ -557,7 +562,9 @@ static errno_t lookup_netgr_step(struct
}
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 */
@@ -585,8 +592,11 @@ static errno_t lookup_netgr_step(struct
}
set_netgr_lifetime(step_ctx->nctx->neg_timeout, step_ctx, netgr);
}
+ ret = ENOENT;
- return ENOENT;
+done:
+ talloc_free(name);
+ return ret;
}
static void lookup_netgr_dp_callback(uint16_t err_maj, uint32_t err_min,