summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-06-26 20:51:17 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-06-26 14:10:17 +0200
commitff4d8fcd8d69e19608cc5b8bd65ca022d714c95a (patch)
tree0c3daa8026478a3b58623a14df7f5d239aefcd09 /source3/passdb
parent5df1fda0f5f775c0ccf23412b29b2fd8b013156e (diff)
downloadsamba-ff4d8fcd8d69e19608cc5b8bd65ca022d714c95a.tar.gz
samba-ff4d8fcd8d69e19608cc5b8bd65ca022d714c95a.tar.bz2
samba-ff4d8fcd8d69e19608cc5b8bd65ca022d714c95a.zip
s3-pdb_samba4: Allocate and free a talloc_stackframe() in pdb_samba4_replace_by_sam()
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_samba4.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source3/passdb/pdb_samba4.c b/source3/passdb/pdb_samba4.c
index 22a59084d7..c94f29c7ae 100644
--- a/source3/passdb/pdb_samba4.c
+++ b/source3/passdb/pdb_samba4.c
@@ -335,6 +335,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
struct ldb_dn *dn,
struct samu *sam)
{
+ TALLOC_CTX *frame = talloc_stackframe();
int ret = LDB_SUCCESS;
const char *pw;
struct ldb_message *msg;
@@ -342,7 +343,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
uint32_t dsdb_flags = 0;
/* TODO: All fields :-) */
- msg = ldb_msg_new(talloc_tos());
+ msg = ldb_msg_new(frame);
if (!msg) {
return false;
}
@@ -350,11 +351,11 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
msg->dn = dn;
/* build modify request */
- ret = ldb_build_mod_req(&req, state->ldb, talloc_tos(), msg, NULL, NULL,
+ ret = ldb_build_mod_req(&req, state->ldb, frame, msg, NULL, NULL,
ldb_op_default_callback,
NULL);
if (ret != LDB_SUCCESS) {
- talloc_free(msg);
+ talloc_free(frame);
return ret;
}
@@ -371,6 +372,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
if (need_update(sam, PDB_PLAINTEXT_PW)) {
struct ldb_val pw_utf16;
if (pw == NULL) {
+ talloc_free(frame);
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -476,9 +478,11 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
uint32_t rid;
NTSTATUS status = dom_sid_split_rid(NULL, sid, NULL, &rid);
if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(frame);
return LDB_ERR_OPERATIONS_ERROR;
}
if (!dom_sid_in_domain(samdb_domain_sid(state->ldb), sid)) {
+ talloc_free(frame);
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
ret |= samdb_msg_add_uint(state->ldb, msg, msg, "primaryGroupID", rid);
@@ -576,10 +580,12 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
*/
if (ret != LDB_SUCCESS) {
+ talloc_free(frame);
return LDB_ERR_OPERATIONS_ERROR;
}
if (msg->num_elements == 0) {
+ talloc_free(frame);
/* Nothing to do, just return success */
return LDB_SUCCESS;
}
@@ -592,6 +598,7 @@ static int pdb_samba4_replace_by_sam(struct pdb_samba4_state *state,
ldb_errstring(state->ldb)));
}
+ talloc_free(frame);
return ret;
}