From 17424588c5d7b7dd1cda5eb6ca0d7d13524b963a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 25 Feb 2013 15:48:20 +0100 Subject: dsdb: Check for pointers before we deference them. Reviewed-by: David Disseldorp --- source4/dsdb/common/dsdb_dn.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source4') diff --git a/source4/dsdb/common/dsdb_dn.c b/source4/dsdb/common/dsdb_dn.c index b53de409fe..0029f5d49e 100644 --- a/source4/dsdb/common/dsdb_dn.c +++ b/source4/dsdb/common/dsdb_dn.c @@ -87,6 +87,11 @@ struct dsdb_dn *dsdb_dn_parse(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, char *dn_str; enum dsdb_dn_format dn_format = dsdb_dn_oid_to_format(dn_oid); + + if (dn_blob == NULL || dn_blob->data == NULL || dn_blob->length == 0) { + return NULL; + } + switch (dn_format) { case DSDB_INVALID_DN: return NULL; @@ -113,16 +118,11 @@ struct dsdb_dn *dsdb_dn_parse(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, return NULL; } - if (dn_blob && dn_blob->data - && (strlen((const char*)dn_blob->data) != dn_blob->length)) { + if (strlen((const char*)dn_blob->data) != dn_blob->length) { /* The RDN must not contain a character with value 0x0 */ return NULL; } - - if (!dn_blob->data || dn_blob->length == 0) { - return NULL; - } - + tmp_ctx = talloc_new(mem_ctx); if (tmp_ctx == NULL) { return NULL; -- cgit