From 27d7f6a31203c6ab3c5b1e3d667fc1c4c79d334f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 13 Jan 2011 11:08:40 +1100 Subject: s4-dsdb: validate number of extended components this checks that the number of extended components in a DN is valid, to match MS AD behaviour. We need to do this to ensure that our tools don't try to do operations that will be invalid when used against MS servers Pair-Programmed-With: Andrew Bartlett --- source4/dsdb/samdb/ldb_modules/extended_dn_in.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source4/dsdb/samdb') diff --git a/source4/dsdb/samdb/ldb_modules/extended_dn_in.c b/source4/dsdb/samdb/ldb_modules/extended_dn_in.c index 39e69d9b1e..4071adda79 100644 --- a/source4/dsdb/samdb/ldb_modules/extended_dn_in.c +++ b/source4/dsdb/samdb/ldb_modules/extended_dn_in.c @@ -273,6 +273,12 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req } else { /* It looks like we need to map the DN */ const struct ldb_val *sid_val, *guid_val, *wkguid_val; + int num_components = ldb_dn_get_comp_num(dn); + int num_ex_components = ldb_dn_get_extended_comp_num(dn); + + if (num_components != 0 || num_ex_components != 1) { + return ldb_error(ldb_module_get_ctx(module), LDB_ERR_INVALID_DN_SYNTAX, "invalid number of DN components"); + } sid_val = ldb_dn_get_extended_component(dn, "SID"); guid_val = ldb_dn_get_extended_component(dn, "GUID"); @@ -311,7 +317,8 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req p = strchr(wkguid_dup, ','); if (!p) { - return LDB_ERR_INVALID_DN_SYNTAX; + return ldb_error(ldb_module_get_ctx(module), LDB_ERR_INVALID_DN_SYNTAX, + "Invalid WKGUID format"); } p[0] = '\0'; @@ -336,7 +343,8 @@ static int extended_dn_in_fix(struct ldb_module *module, struct ldb_request *req base_dn_scope = LDB_SCOPE_BASE; base_dn_attrs = wkattr; } else { - return LDB_ERR_INVALID_DN_SYNTAX; + return ldb_error(ldb_module_get_ctx(module), LDB_ERR_INVALID_DN_SYNTAX, + "Invalid extended DN component"); } ac = talloc_zero(req, struct extended_search_context); -- cgit