From 68f33428c7736966caa98cd85b2ef15e71d5fad8 Mon Sep 17 00:00:00 2001 From: Anatoliy Atanasov Date: Tue, 22 Sep 2009 14:37:58 -0700 Subject: Move the check above the talloc --- source4/lib/ldb/common/ldb_dn.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source4') diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index af00ef96f3..12a513fc42 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -88,6 +88,12 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, if (! ldb) return NULL; + if (strdn && strdn->data + && (strlen((const char*)strdn->data) != strdn->length)) { + /* The RDN must not contain a character with value 0x0 */ + return NULL; + } + dn = talloc_zero(mem_ctx, struct ldb_dn); LDB_DN_NULL_FAILED(dn); @@ -103,11 +109,6 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, dn->ext_linearized = talloc_strndup(dn, data, length); LDB_DN_NULL_FAILED(dn->ext_linearized); - if (strlen(data) != length) { - /* The RDN must not contain a character with value 0x0 */ - return NULL; - } - if (data[0] == '<') { const char *p_save, *p = dn->ext_linearized; do { -- cgit