summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-01-09 09:03:08 +1100
committerAndrew Tridgell <tridge@samba.org>2010-01-09 10:15:12 +1100
commit39a4e2a38d0a6767ebca13efaee0ac61297ad45b (patch)
treee6dfd6f18c4996f517d238ebc55e5c1295fbf90c /source4/lib
parent7eee8e053b22b9be8cd6de5a27efb19fe914039a (diff)
downloadsamba-39a4e2a38d0a6767ebca13efaee0ac61297ad45b.tar.gz
samba-39a4e2a38d0a6767ebca13efaee0ac61297ad45b.tar.bz2
samba-39a4e2a38d0a6767ebca13efaee0ac61297ad45b.zip
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
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c8
1 files changed, 7 insertions, 1 deletions
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;