From 43555d6439460d2bafa54300221856142c83aa3f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 26 Jun 2012 20:53:08 +1000 Subject: s4-samldb: do not talloc_steal() the elements of the original request --- source4/dsdb/samdb/ldb_modules/samldb.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source4/dsdb') diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index a859fc9c73..bb306055f2 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -1689,8 +1689,10 @@ static int samldb_sam_accountname_check(struct samldb_ctx *ac) if (ret != LDB_SUCCESS) { return ret; } - sam_accountname = talloc_steal(ac, - ldb_msg_find_attr_as_string(tmp_msg, "sAMAccountName", NULL)); + + /* We must not steal the original string, it belongs to the caller! */ + sam_accountname = talloc_strdup(ac, + ldb_msg_find_attr_as_string(tmp_msg, "sAMAccountName", NULL)); talloc_free(tmp_msg); if (sam_accountname == NULL) { @@ -1901,8 +1903,12 @@ static int samldb_service_principal_names_change(struct samldb_ctx *ac) if (ret != LDB_SUCCESS) { return ret; } - dns_hostname = talloc_steal(ac, - ldb_msg_find_attr_as_string(msg, "dNSHostName", NULL)); + dns_hostname = talloc_strdup(ac, + ldb_msg_find_attr_as_string(msg, "dNSHostName", NULL)); + if (dns_hostname == NULL) { + return ldb_module_oom(ac->module); + } + talloc_free(msg); ret = dsdb_module_search_dn(ac->module, ac, &res, ac->msg->dn, -- cgit