mirror of
https://github.com/samba-team/samba.git
synced 2025-03-07 00:58:40 +03:00
registry: use talloc instead of malloc and provide common exit point
in regdb_get_secdesc(). Michael (This used to be commit df848d8eeeb102288a3acb9a0f8a7015e0c6ca6b)
This commit is contained in:
parent
647432a40c
commit
9741e07140
@ -877,35 +877,35 @@ static WERROR regdb_get_secdesc(TALLOC_CTX *mem_ctx, const char *key,
|
|||||||
TDB_DATA data;
|
TDB_DATA data;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
||||||
|
WERROR err = WERR_OK;
|
||||||
|
|
||||||
DEBUG(10, ("regdb_get_secdesc: Getting secdesc of key [%s]\n", key));
|
DEBUG(10, ("regdb_get_secdesc: Getting secdesc of key [%s]\n", key));
|
||||||
|
|
||||||
if (asprintf(&tdbkey, "%s/%s", REG_SECDESC_PREFIX, key) == -1) {
|
tdbkey = talloc_asprintf(tmp_ctx, "%s/%s", REG_SECDESC_PREFIX, key);
|
||||||
return WERR_NOMEM;
|
if (tdbkey == NULL) {
|
||||||
|
err = WERR_NOMEM;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
normalize_dbkey(tdbkey);
|
normalize_dbkey(tdbkey);
|
||||||
|
|
||||||
data = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey);
|
data = dbwrap_fetch_bystring(regdb, tmp_ctx, tdbkey);
|
||||||
SAFE_FREE(tdbkey);
|
|
||||||
|
|
||||||
if (data.dptr == NULL) {
|
if (data.dptr == NULL) {
|
||||||
return WERR_BADFILE;
|
err = WERR_BADFILE;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = unmarshall_sec_desc(mem_ctx, (uint8 *)data.dptr, data.dsize,
|
status = unmarshall_sec_desc(mem_ctx, (uint8 *)data.dptr, data.dsize,
|
||||||
psecdesc);
|
psecdesc);
|
||||||
|
|
||||||
TALLOC_FREE(tmp_ctx);
|
|
||||||
|
|
||||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MEMORY)) {
|
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)) {
|
done:
|
||||||
return WERR_REG_CORRUPT;
|
TALLOC_FREE(tmp_ctx);
|
||||||
}
|
return err;
|
||||||
|
|
||||||
return WERR_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static WERROR regdb_set_secdesc(const char *key,
|
static WERROR regdb_set_secdesc(const char *key,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user