svn commit: samba r17698 - in
branches/SAMBA_4_0/source/lib/ldb/modules: .
abartlet at samba.org
abartlet at samba.org
Tue Aug 22 06:01:47 GMT 2006
Author: abartlet
Date: 2006-08-22 06:01:47 +0000 (Tue, 22 Aug 2006)
New Revision: 17698
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17698
Log:
The original code assumed that &data->context was a valid talloc
pointer.
This only works when this is the only structure member, but when I
added a new context pointer, it failed.
Andrew Bartlett
Modified:
branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c
branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c 2006-08-22 05:33:52 UTC (rev 17697)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.c 2006-08-22 06:01:47 UTC (rev 17698)
@@ -99,7 +99,7 @@
const struct ldb_map_context *map_get_context(struct ldb_module *module)
{
const struct map_private *data = talloc_get_type(module->private_data, struct map_private);
- return &data->context;
+ return data->context;
}
/* Create a generic request context. */
@@ -338,35 +338,37 @@
/* Find an attribute mapping by the remote name. */
const struct ldb_map_attribute *map_attr_find_remote(const struct ldb_map_context *data, const char *name)
{
+ const struct ldb_map_attribute *map;
const struct ldb_map_attribute *wildcard = NULL;
int i, j;
for (i = 0; data->attribute_maps[i].local_name; i++) {
- if (ldb_attr_cmp(data->attribute_maps[i].local_name, "*") == 0) {
+ map = &data->attribute_maps[i];
+ if (ldb_attr_cmp(map->local_name, "*") == 0) {
wildcard = &data->attribute_maps[i];
}
- switch (data->attribute_maps[i].type) {
+ switch (map->type) {
case MAP_IGNORE:
break;
case MAP_KEEP:
- if (ldb_attr_cmp(data->attribute_maps[i].local_name, name) == 0) {
- return &data->attribute_maps[i];
+ if (ldb_attr_cmp(map->local_name, name) == 0) {
+ return map;
}
break;
case MAP_RENAME:
case MAP_CONVERT:
- if (ldb_attr_cmp(data->attribute_maps[i].u.rename.remote_name, name) == 0) {
- return &data->attribute_maps[i];
+ if (ldb_attr_cmp(map->u.rename.remote_name, name) == 0) {
+ return map;
}
break;
case MAP_GENERATE:
- for (j = 0; data->attribute_maps[i].u.generate.remote_names[j]; j++) {
- if (ldb_attr_cmp(data->attribute_maps[i].u.generate.remote_names[j], name) == 0) {
- return &data->attribute_maps[i];
+ for (j = 0; map->u.generate.remote_names && map->u.generate.remote_names[j]; j++) {
+ if (ldb_attr_cmp(map->u.generate.remote_names[j], name) == 0) {
+ return map;
}
}
break;
@@ -1283,15 +1285,21 @@
module->private_data = data;
+ data->context = talloc_zero(data, struct ldb_map_context);
+ if (!data->context) {
+ map_oom(module);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
/* Store local and remote baseDNs */
- ret = map_init_dns(module, &(data->context), name);
+ ret = map_init_dns(module, data->context, name);
if (ret != LDB_SUCCESS) {
talloc_free(data);
return ret;
}
/* Store list of attribute and objectClass maps */
- ret = map_init_maps(module, &(data->context), attrs, ocls);
+ ret = map_init_maps(module, data->context, attrs, ocls);
if (ret != LDB_SUCCESS) {
talloc_free(data);
return ret;
Modified: branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h 2006-08-22 05:33:52 UTC (rev 17697)
+++ branches/SAMBA_4_0/source/lib/ldb/modules/ldb_map.h 2006-08-22 06:01:47 UTC (rev 17698)
@@ -138,7 +138,7 @@
/* Global private data */
struct map_private {
void *caller_private;
- struct ldb_map_context context;
+ struct ldb_map_context *context;
};
/* initialization function */
More information about the samba-cvs
mailing list