summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-03-17 01:39:16 +0100
committerMichael Adam <obnox@samba.org>2008-03-17 08:22:33 +0100
commit9741e071403145d0c6902e8998b54f1f18be263b (patch)
tree451b55ccfa09e252c474b6bba0cd6ad0ed7e8605 /source3
parent647432a40c5b87c6c24157270e24f2bdb628a112 (diff)
downloadsamba-9741e071403145d0c6902e8998b54f1f18be263b.tar.gz
samba-9741e071403145d0c6902e8998b54f1f18be263b.tar.bz2
samba-9741e071403145d0c6902e8998b54f1f18be263b.zip
registry: use talloc instead of malloc and provide common exit point
in regdb_get_secdesc(). Michael (This used to be commit df848d8eeeb102288a3acb9a0f8a7015e0c6ca6b)
Diffstat (limited to 'source3')
-rw-r--r--source3/registry/reg_backend_db.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index fb071ae273..9b388767ec 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -877,35 +877,35 @@ static WERROR regdb_get_secdesc(TALLOC_CTX *mem_ctx, const char *key,
TDB_DATA data;
NTSTATUS status;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ WERROR err = WERR_OK;
DEBUG(10, ("regdb_get_secdesc: Getting secdesc of key [%s]\n", key));
- if (asprintf(&tdbkey, "%s/%s", REG_SECDESC_PREFIX, key) == -1) {
- return WERR_NOMEM;
+ tdbkey = talloc_asprintf(tmp_ctx, "%s/%s", REG_SECDESC_PREFIX, key);
+ if (tdbkey == NULL) {
+ err = WERR_NOMEM;
+ goto done;
}
normalize_dbkey(tdbkey);
data = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey);
- SAFE_FREE(tdbkey);
-
if (data.dptr == NULL) {
- return WERR_BADFILE;
+ err = WERR_BADFILE;
+ goto done;
}
status = unmarshall_sec_desc(mem_ctx, (uint8 *)data.dptr, data.dsize,
psecdesc);
- TALLOC_FREE(tmp_ctx);
-
if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) {
- return WERR_NOMEM;
+ err = WERR_NOMEM;
+ } else if (!NT_STATUS_IS_OK(status)) {
+ err = WERR_REG_CORRUPT;
}
- if (!NT_STATUS_IS_OK(status)) {
- return WERR_REG_CORRUPT;
- }
-
- return WERR_OK;
+done:
+ TALLOC_FREE(tmp_ctx);
+ return err;
}
static WERROR regdb_set_secdesc(const char *key,