summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-09-10 13:35:56 +0200
committerMichael Adam <obnox@samba.org>2013-10-02 00:50:07 +0200
commit8371f5981dea11ac29451ccccac345e5a0350b5d (patch)
treea9474433478e557c3839151af90c683801750522 /source3
parent5aed3fabac20f026f68fc72aec0ff3e67e0478ae (diff)
downloadsamba-8371f5981dea11ac29451ccccac345e5a0350b5d.tar.gz
samba-8371f5981dea11ac29451ccccac345e5a0350b5d.tar.bz2
samba-8371f5981dea11ac29451ccccac345e5a0350b5d.zip
idmap_autorid: improve clarity of idmap_autorid_addrange_action() by adding mem_ctx.
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/idmap_autorid_tdb.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/source3/winbindd/idmap_autorid_tdb.c b/source3/winbindd/idmap_autorid_tdb.c
index d66f01289d..9c77f24448 100644
--- a/source3/winbindd/idmap_autorid_tdb.c
+++ b/source3/winbindd/idmap_autorid_tdb.c
@@ -74,6 +74,7 @@ static NTSTATUS idmap_autorid_addrange_action(struct db_context *db,
struct autorid_global_config *globalcfg;
fstring keystr;
uint32_t increment;
+ TALLOC_CTX *mem_ctx = NULL;
ctx = (struct idmap_autorid_addrange_ctx *)private_data;
range = ctx->range;
@@ -129,11 +130,12 @@ static NTSTATUS idmap_autorid_addrange_action(struct db_context *db,
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(1, ("Fatal error while fetching current "
"HWM value: %s\n", nt_errstr(ret)));
- ret = NT_STATUS_INTERNAL_ERROR;
- goto error;
+ return NT_STATUS_INTERNAL_ERROR;
}
- ret = idmap_autorid_loadconfig(db, talloc_tos(), &globalcfg);
+ mem_ctx = talloc_stackframe();
+
+ ret = idmap_autorid_loadconfig(db, mem_ctx, &globalcfg);
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(1, ("Fatal error while fetching configuration: %s\n",
nt_errstr(ret)));
@@ -167,7 +169,6 @@ static NTSTATUS idmap_autorid_addrange_action(struct db_context *db,
ret = NT_STATUS_NO_MEMORY;
goto error;
}
- TALLOC_FREE(globalcfg);
/* HWM always contains current max range + 1 */
increment = requested_rangenum + 1 - hwm;
@@ -188,7 +189,7 @@ static NTSTATUS idmap_autorid_addrange_action(struct db_context *db,
goto error;
}
- numstr = talloc_asprintf(talloc_tos(), "%u", requested_rangenum);
+ numstr = talloc_asprintf(mem_ctx, "%u", requested_rangenum);
if (!numstr) {
ret = NT_STATUS_NO_MEMORY;
goto error;
@@ -197,7 +198,6 @@ static NTSTATUS idmap_autorid_addrange_action(struct db_context *db,
ret = dbwrap_store_bystring(db, numstr,
string_term_tdb_data(keystr), TDB_INSERT);
- talloc_free(numstr);
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(1, ("Fatal error while storing new "
"domain->range assignment: %s\n", nt_errstr(ret)));
@@ -212,9 +212,10 @@ static NTSTATUS idmap_autorid_addrange_action(struct db_context *db,
range->low_id = globalcfg->minvalue
+ range->rangenum * globalcfg->rangesize;
- return NT_STATUS_OK;
+ ret = NT_STATUS_OK;
error:
+ talloc_free(mem_ctx);
return ret;
}