From 39a4e2a38d0a6767ebca13efaee0ac61297ad45b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Jan 2010 09:03:08 +1100 Subject: s4-ldb: validate the type of the ldb argument to ldb_dn_new() It has been a common bug to get the first two arguments the wrong way around --- source4/lib/ldb/common/ldb_dn.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/lib') diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index 79953c6018..252a0c632b 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -103,7 +103,13 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, dn = talloc_zero(mem_ctx, struct ldb_dn); LDB_DN_NULL_FAILED(dn); - dn->ldb = ldb; + dn->ldb = talloc_get_type(ldb, struct ldb_context); + if (dn->ldb == NULL) { + /* the caller probably got the arguments to + ldb_dn_new() mixed up */ + talloc_free(dn); + return NULL; + } if (strdn->data && strdn->length) { const char *data = (const char *)strdn->data; -- cgit