diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-08-22 06:01:47 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:16:27 -0500 |
commit | cda3a37d76872c9243420904b0cf92a38d3cdb5d (patch) | |
tree | 56870688df20e610212d63243c4b89218824cc4a /source4 | |
parent | 1d1f100a730f5fc8b6cffd1079ed1563248b55f2 (diff) | |
download | samba-cda3a37d76872c9243420904b0cf92a38d3cdb5d.tar.gz samba-cda3a37d76872c9243420904b0cf92a38d3cdb5d.tar.bz2 samba-cda3a37d76872c9243420904b0cf92a38d3cdb5d.zip |
r17698: 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
(This used to be commit 5bcfa12cef0d9eba5d5d1f65f676e7852297667f)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/ldb/modules/ldb_map.c | 32 | ||||
-rw-r--r-- | source4/lib/ldb/modules/ldb_map.h | 2 |
2 files changed, 21 insertions, 13 deletions
diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c index 5f14e96dd8..2bc3416a93 100644 --- a/source4/lib/ldb/modules/ldb_map.c +++ b/source4/lib/ldb/modules/ldb_map.c @@ -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 @@ const struct ldb_map_attribute *map_attr_find_local(const struct ldb_map_context /* 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 @@ int ldb_map_init(struct ldb_module *module, const struct ldb_map_attribute *attr 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; diff --git a/source4/lib/ldb/modules/ldb_map.h b/source4/lib/ldb/modules/ldb_map.h index edd3eca871..e743970564 100644 --- a/source4/lib/ldb/modules/ldb_map.h +++ b/source4/lib/ldb/modules/ldb_map.h @@ -138,7 +138,7 @@ struct ldb_map_context { /* Global private data */ struct map_private { void *caller_private; - struct ldb_map_context context; + struct ldb_map_context *context; }; /* initialization function */ |