diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-12-09 14:34:13 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-12-09 18:18:25 +1100 |
commit | 707cd30cda11acdcad59cfdb6743eb822f69f5ba (patch) | |
tree | 0a1457a90ee1ea578156bd81e86af50f6e843774 /source4/dsdb | |
parent | f7723293a07d1b7a4f3476939590fa8db6080d06 (diff) | |
download | samba-707cd30cda11acdcad59cfdb6743eb822f69f5ba.tar.gz samba-707cd30cda11acdcad59cfdb6743eb822f69f5ba.tar.bz2 samba-707cd30cda11acdcad59cfdb6743eb822f69f5ba.zip |
s4-dsdb: fixed steal of parentGUID for empty msg
msg->elements could be NULL before we add parentGUID
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/samdb/ldb_modules/operational.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/operational.c b/source4/dsdb/samdb/ldb_modules/operational.c index badc0c5fa1..aef9598625 100644 --- a/source4/dsdb/samdb/ldb_modules/operational.c +++ b/source4/dsdb/samdb/ldb_modules/operational.c @@ -125,11 +125,12 @@ static int construct_parent_guid(struct ldb_module *module, const struct ldb_val *parent_guid; const char *attrs[] = { "objectGUID", NULL }; int ret; + struct ldb_val v; /* TODO: In the future, this needs to honour the partition boundaries */ struct ldb_dn *parent_dn = ldb_dn_get_parent(msg, msg->dn); - if (parent_dn == NULL){ + if (parent_dn == NULL) { DEBUG(4,(__location__ ": Failed to find parent for dn %s\n", ldb_dn_get_linearized(msg->dn))); return LDB_SUCCESS; @@ -138,7 +139,7 @@ static int construct_parent_guid(struct ldb_module *module, ret = dsdb_module_search_dn(module, msg, &res, parent_dn, attrs, DSDB_SEARCH_SHOW_DELETED); talloc_free(parent_dn); /* if there is no parentGUID for this object, then return */ - if (ret == LDB_ERR_NO_SUCH_OBJECT){ + if (ret == LDB_ERR_NO_SUCH_OBJECT) { DEBUG(4,(__location__ ": Parent dn for %s does not exist \n", ldb_dn_get_linearized(msg->dn))); return LDB_SUCCESS; @@ -152,9 +153,14 @@ static int construct_parent_guid(struct ldb_module *module, return LDB_SUCCESS; } - talloc_steal(msg->elements, parent_guid->data); + v = data_blob_dup_talloc(res, parent_guid); + if (!v.data) { + talloc_free(res); + return LDB_ERR_OPERATIONS_ERROR; + } + ret = ldb_msg_add_steal_value(msg, "parentGUID", &v); talloc_free(res); - return ldb_msg_add_value(msg, "parentGUID", parent_guid, 0); + return ret; } /* |