From be9441ac3fa167f97f54700e52dec9995b170fa3 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 24 Aug 2009 20:22:18 +1000 Subject: s4:dsdb Use talloc_strndup() to ensure OIDs are null terminated The OIDs are not NULL terminated by the python caller, in line with the LDB API, but we need them to be here, as we were casting them to a string. Andrew Bartlett --- source4/dsdb/samdb/ldb_modules/schema_fsmo.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'source4/dsdb/samdb/ldb_modules') diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c index adc0fe41d0..c482ab57df 100644 --- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c +++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c @@ -172,8 +172,8 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) { struct ldb_context *ldb; struct dsdb_schema *schema; - const char *attributeID = NULL; - const char *governsID = NULL; + const struct ldb_val *attributeID = NULL; + const struct ldb_val *governsID = NULL; const char *oid_attr = NULL; const char *oid = NULL; uint32_t id32; @@ -202,21 +202,24 @@ static int schema_fsmo_add(struct ldb_module *module, struct ldb_request *req) return LDB_ERR_UNWILLING_TO_PERFORM; } - attributeID = samdb_result_string(req->op.add.message, "attributeID", NULL); - governsID = samdb_result_string(req->op.add.message, "governsID", NULL); + attributeID = ldb_msg_find_ldb_val(req->op.add.message, "attributeID"); + governsID = ldb_msg_find_ldb_val(req->op.add.message, "governsID"); if (attributeID) { oid_attr = "attributeID"; - oid = attributeID; + oid = talloc_strndup(req, (const char *)attributeID->data, attributeID->length); } else if (governsID) { oid_attr = "governsID"; - oid = governsID; + oid = talloc_strndup(req, (const char *)governsID->data, governsID->length); + } else { + return ldb_next_request(module, req); } if (!oid) { - return ldb_next_request(module, req); + ldb_oom(ldb); + return LDB_ERR_OPERATIONS_ERROR; } - + status = dsdb_map_oid2int(schema, oid, &id32); if (W_ERROR_IS_OK(status)) { return ldb_next_request(module, req); -- cgit