summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb_msg.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-07-06 05:08:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:47 -0500
commit44e6f21393ea6f2531c6d1e789a0a01582bc6dca (patch)
tree3d34180ed1de88b3e0e8e63832fb138ba4e33b96 /source4/lib/ldb/common/ldb_msg.c
parent927cbf74ae1c08876a717f739449177d03740f2e (diff)
downloadsamba-44e6f21393ea6f2531c6d1e789a0a01582bc6dca.tar.gz
samba-44e6f21393ea6f2531c6d1e789a0a01582bc6dca.tar.bz2
samba-44e6f21393ea6f2531c6d1e789a0a01582bc6dca.zip
r16825: Make ldb_sainity_check() set an error string. This makes it much
easier to chase down what modules or application code gets wrong. Ensure not to leave memory allocated on failure in ldb_search() Andrew Bartlett (This used to be commit 0828739951ed879640f8ed6e4700d8ca6b8221b8)
Diffstat (limited to 'source4/lib/ldb/common/ldb_msg.c')
-rw-r--r--source4/lib/ldb/common/ldb_msg.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/source4/lib/ldb/common/ldb_msg.c b/source4/lib/ldb/common/ldb_msg.c
index bae17e7046..797d050975 100644
--- a/source4/lib/ldb/common/ldb_msg.c
+++ b/source4/lib/ldb/common/ldb_msg.c
@@ -550,18 +550,20 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
return mod;
}
-int ldb_msg_sanity_check(const struct ldb_message *msg)
+int ldb_msg_sanity_check(struct ldb_context *ldb,
+ const struct ldb_message *msg)
{
int i, j;
/* basic check on DN */
if (msg->dn == NULL) {
/* TODO: return also an error string */
+ ldb_set_errstring(ldb, talloc_strdup(ldb, "ldb message lacks a DN!"));
return LDB_ERR_INVALID_DN_SYNTAX;
}
if (msg->dn->comp_num == 0) {
/* root dse has empty dn */
- /* TODO: return also an error string */
+ ldb_set_errstring(ldb, talloc_strdup(ldb, "DN on new ldb message is '' (not permitted)!"));
return LDB_ERR_ENTRY_ALREADY_EXISTS;
}
@@ -569,8 +571,13 @@ int ldb_msg_sanity_check(const struct ldb_message *msg)
for (i = 0; i < msg->num_elements; i++) {
for (j = 0; j < msg->elements[i].num_values; j++) {
if (msg->elements[i].values[j].length == 0) {
+ TALLOC_CTX *mem_ctx = talloc_new(ldb);
/* an attribute cannot be empty */
/* TODO: return also an error string */
+ ldb_set_errstring(ldb, talloc_asprintf(mem_ctx, "Element %s has empty attribute in ldb message (%s)!",
+ msg->elements[i].name,
+ ldb_dn_linearize(mem_ctx, msg->dn)));
+ talloc_free(mem_ctx);
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
}