summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2007-01-02 03:39:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:35:51 -0500
commit0311a5396b1740c3a0f0cdde7a2e5da4be50d4bd (patch)
treef5bc8e3e1ff013c36fc3716e03bbda9c4242b653 /source4
parentca6a8c5f0b23a001d39082ac55db354926ac6349 (diff)
downloadsamba-0311a5396b1740c3a0f0cdde7a2e5da4be50d4bd.tar.gz
samba-0311a5396b1740c3a0f0cdde7a2e5da4be50d4bd.tar.bz2
samba-0311a5396b1740c3a0f0cdde7a2e5da4be50d4bd.zip
r20459: LDB map cleanup:
- Replace 'return 0' with return LDB_SUCCESS in more places. - Do not return NULL attribute values, these are not permitted. Instead, fail the whole conversion. - Cleanup old comments. Andrew Bartlett (This used to be commit f28cf842dab2fe5e691d755f28c6048c986e284f)
Diffstat (limited to 'source4')
-rw-r--r--source4/lib/ldb/modules/ldb_map_outbound.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/source4/lib/ldb/modules/ldb_map_outbound.c b/source4/lib/ldb/modules/ldb_map_outbound.c
index b1eb313060..a9bfd8d113 100644
--- a/source4/lib/ldb/modules/ldb_map_outbound.c
+++ b/source4/lib/ldb/modules/ldb_map_outbound.c
@@ -229,8 +229,7 @@ static struct ldb_message_element *ldb_msg_el_map_remote(struct ldb_module *modu
return NULL;
}
- el->num_values = old->num_values;
- el->values = talloc_array(el, struct ldb_val, el->num_values);
+ el->values = talloc_array(el, struct ldb_val, old->num_values);
if (el->values == NULL) {
talloc_free(el);
map_oom(module);
@@ -244,8 +243,14 @@ static struct ldb_message_element *ldb_msg_el_map_remote(struct ldb_module *modu
return NULL;
}
- for (i = 0; i < el->num_values; i++) {
+ for (i = 0; i < old->num_values; i++) {
el->values[i] = ldb_val_map_remote(module, el->values, map, &old->values[i]);
+ /* Conversions might fail, in which case bail */
+ if (!el->values[i].data) {
+ talloc_free(el);
+ return NULL;
+ }
+ el->num_values++;
}
return el;
@@ -262,7 +267,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
/* We handle wildcards in ldb_msg_el_merge_wildcard */
if (ldb_attr_cmp(attr_name, "*") == 0) {
- return 0;
+ return LDB_SUCCESS;
}
map = map_attr_find_local(data, attr_name);
@@ -270,7 +275,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
/* Unknown attribute in remote message:
* skip, attribute was probably auto-generated */
if (map == NULL) {
- return 0;
+ return LDB_SUCCESS;
}
switch (map->type) {
@@ -291,7 +296,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
switch (map->type) {
case MAP_IGNORE:
- return 0;
+ return LDB_SUCCESS;
case MAP_CONVERT:
if (map->u.convert.convert_remote == NULL) {
@@ -299,7 +304,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
"Skipping attribute '%s': "
"'convert_remote' not set\n",
attr_name);
- return 0;
+ return LDB_SUCCESS;
}
/* fall through */
case MAP_KEEP:
@@ -318,7 +323,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
"Skipping attribute '%s': "
"'generate_local' not set\n",
attr_name);
- return 0;
+ return LDB_SUCCESS;
}
el = map->u.generate.generate_local(module, local, attr_name, remote);
@@ -330,7 +335,7 @@ static int ldb_msg_el_merge(struct ldb_module *module, struct ldb_message *local
}
if (el == NULL) {
- return LDB_ERR_OPERATIONS_ERROR;
+ return LDB_ERR_NO_SUCH_ATTRIBUTE;
}
return ldb_msg_replace(local, el);
@@ -376,7 +381,7 @@ static int ldb_msg_el_merge_wildcard(struct ldb_module *module, struct ldb_messa
}
}
- return 0;
+ return LDB_SUCCESS;
}
/* Mapping messages
@@ -394,7 +399,7 @@ static int ldb_msg_merge_local(struct ldb_module *module, struct ldb_message *ms
}
}
- return 0;
+ return LDB_SUCCESS;
}
/* Merge a local and a remote message into a single local one. */
@@ -432,7 +437,7 @@ static int ldb_msg_merge_remote(struct map_context *ac, struct ldb_message *loca
}
}
- return 0;
+ return LDB_SUCCESS;
}
/* Mapping search results
@@ -942,10 +947,6 @@ static int map_attrs_collect_and_partition(struct ldb_module *module, struct map
const char **local_attrs;
int ret;
- /* Clear initial lists of partitioned attributes */
-
- /* Clear initial lists of partitioned attributes */
-
/* There is no tree, just partition the searched attributes */
if (tree == NULL) {
ret = map_attrs_partition(module, ac,