The branch, master has been updated via 0941099 ldb:ldb_index.c - fix some memory leaks via 3bf8ca6 ldb:ldb_index.c - let "ldb_module_oom" generate the return code via ec43a4d ldb:ldb_cache.c - fix memory contexts and memory leaks via 06053a0 ldb:ldb_tdb submodule - use "ldb_msg_new" where appropriate via 1427895 ldb:ldb_pack.c - remove superflous "message->elements = NULL" via caf6b36 libcli/security/access_check.c - fix a memory leak from efb22bf s3: Add some DEBUG
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 0941099a2839812b18c2d3db86b18e92b152f1c8 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Wed Oct 20 14:27:04 2010 +0200 ldb:ldb_index.c - fix some memory leaks Autobuild-User: Matthias Dieter Wallnöfer <m...@samba.org> Autobuild-Date: Wed Oct 20 13:11:49 UTC 2010 on sn-devel-104 commit 3bf8ca67900a10e608808535358a148455827a2e Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Wed Oct 20 14:26:37 2010 +0200 ldb:ldb_index.c - let "ldb_module_oom" generate the return code commit ec43a4d29e3bb395e7a8d7edafb6dedfeb9baec2 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Wed Oct 20 14:08:53 2010 +0200 ldb:ldb_cache.c - fix memory contexts and memory leaks commit 06053a09cbf42cde12d69d0a296fb25f425aae67 Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Wed Oct 20 13:53:14 2010 +0200 ldb:ldb_tdb submodule - use "ldb_msg_new" where appropriate It is saver than a manual "talloc". commit 1427895531c259f4bb6c561972b79051807c2a4d Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Wed Oct 20 13:47:48 2010 +0200 ldb:ldb_pack.c - remove superflous "message->elements = NULL" It's already marked at this at the beginning of the call. commit caf6b3686fb7f18b17e0b89f519f216ac98df3be Author: Matthias Dieter Wallnöfer <m...@samba.org> Date: Wed Oct 20 13:40:19 2010 +0200 libcli/security/access_check.c - fix a memory leak ----------------------------------------------------------------------- Summary of changes: libcli/security/access_check.c | 19 ++++++++++++------- source4/lib/ldb/ldb_tdb/ldb_cache.c | 23 ++++++++++++----------- source4/lib/ldb/ldb_tdb/ldb_index.c | 30 ++++++++++++++---------------- source4/lib/ldb/ldb_tdb/ldb_pack.c | 1 - source4/lib/ldb/ldb_tdb/ldb_tdb.c | 8 ++++---- 5 files changed, 42 insertions(+), 39 deletions(-) Changeset truncated at 500 lines: diff --git a/libcli/security/access_check.c b/libcli/security/access_check.c index 35ee057..a00e42b 100644 --- a/libcli/security/access_check.c +++ b/libcli/security/access_check.c @@ -287,7 +287,7 @@ NTSTATUS sec_access_check_ds(const struct security_descriptor *sd, uint32_t bits_remaining; struct object_tree *node; const struct GUID *type; - struct dom_sid *ps_sid = dom_sid_parse_talloc(NULL, SID_NT_SELF); + struct dom_sid *ps_sid = dom_sid_parse_talloc(sd, SID_NT_SELF); *access_granted = access_desired; bits_remaining = access_desired; @@ -304,13 +304,15 @@ NTSTATUS sec_access_check_ds(const struct security_descriptor *sd, if (security_token_has_privilege(token, SEC_PRIV_SECURITY)) { bits_remaining &= ~SEC_FLAG_SYSTEM_SECURITY; } else { + talloc_free(ps_sid); return NT_STATUS_PRIVILEGE_NOT_HELD; } } /* a NULL dacl allows access */ if ((sd->type & SEC_DESC_DACL_PRESENT) && sd->dacl == NULL) { - *access_granted = access_desired; + *access_granted = access_desired; + talloc_free(ps_sid); return NT_STATUS_OK; } @@ -356,6 +358,7 @@ NTSTATUS sec_access_check_ds(const struct security_descriptor *sd, break; case SEC_ACE_TYPE_ACCESS_DENIED: if (bits_remaining & ace->access_mask) { + talloc_free(ps_sid); return NT_STATUS_ACCESS_DENIED; } break; @@ -377,12 +380,13 @@ NTSTATUS sec_access_check_ds(const struct security_descriptor *sd, if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT) { object_tree_modify_access(node, ace->access_mask); - if (node->remaining_access == 0) { - return NT_STATUS_OK; - } - } - else { + if (node->remaining_access == 0) { + talloc_free(ps_sid); + return NT_STATUS_OK; + } + } else { if (node->remaining_access & ace->access_mask){ + talloc_free(ps_sid); return NT_STATUS_ACCESS_DENIED; } } @@ -393,6 +397,7 @@ NTSTATUS sec_access_check_ds(const struct security_descriptor *sd, } done: + talloc_free(ps_sid); if (bits_remaining != 0) { return NT_STATUS_ACCESS_DENIED; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c index 2f0ba22..6b1eb5b 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c @@ -203,7 +203,7 @@ static int ltdb_baseinfo_init(struct ldb_module *module) ltdb->sequence_number = atof(initial_sequence_number); - msg = talloc(ltdb, struct ldb_message); + msg = ldb_msg_new(ltdb); if (msg == NULL) { goto failed; } @@ -287,18 +287,18 @@ int ltdb_cache_load(struct ldb_module *module) if (ltdb->cache == NULL) { ltdb->cache = talloc_zero(ltdb, struct ltdb_cache); if (ltdb->cache == NULL) goto failed; - ltdb->cache->indexlist = talloc_zero(ltdb->cache, struct ldb_message); - ltdb->cache->attributes = talloc_zero(ltdb->cache, struct ldb_message); + ltdb->cache->indexlist = ldb_msg_new(ltdb->cache); + ltdb->cache->attributes = ldb_msg_new(ltdb->cache); if (ltdb->cache->indexlist == NULL || ltdb->cache->attributes == NULL) { goto failed; } } - baseinfo = talloc(ltdb->cache, struct ldb_message); + baseinfo = ldb_msg_new(ltdb->cache); if (baseinfo == NULL) goto failed; - baseinfo_dn = ldb_dn_new(module, ldb, LTDB_BASEINFO); + baseinfo_dn = ldb_dn_new(baseinfo, ldb, LTDB_BASEINFO); if (baseinfo_dn == NULL) goto failed; r= ltdb_search_dn1(module, baseinfo_dn, baseinfo); @@ -327,7 +327,7 @@ int ltdb_cache_load(struct ldb_module *module) ltdb->sequence_number = seq; /* Read an interpret database options */ - options = talloc(ltdb->cache, struct ldb_message); + options = ldb_msg_new(ltdb->cache); if (options == NULL) goto failed; options_dn = ldb_dn_new(options, ldb, LTDB_OPTIONS); @@ -351,9 +351,10 @@ int ltdb_cache_load(struct ldb_module *module) ltdb_attributes_unload(module); talloc_free(ltdb->cache->indexlist); + talloc_free(ltdb->cache->attributes); - ltdb->cache->indexlist = talloc_zero(ltdb->cache, struct ldb_message); - ltdb->cache->attributes = talloc_zero(ltdb->cache, struct ldb_message); + ltdb->cache->indexlist = ldb_msg_new(ltdb->cache); + ltdb->cache->attributes = ldb_msg_new(ltdb->cache); if (ltdb->cache->indexlist == NULL || ltdb->cache->attributes == NULL) { goto failed; @@ -383,14 +384,12 @@ int ltdb_cache_load(struct ldb_module *module) done: talloc_free(options); talloc_free(baseinfo); - talloc_free(baseinfo_dn); talloc_free(indexlist_dn); return 0; failed: talloc_free(options); talloc_free(baseinfo); - talloc_free(baseinfo_dn); talloc_free(indexlist_dn); return -1; } @@ -414,7 +413,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module) ldb = ldb_module_get_ctx(module); - msg = talloc(ltdb, struct ldb_message); + msg = ldb_msg_new(ltdb); if (msg == NULL) { errno = ENOMEM; return LDB_ERR_OPERATIONS_ERROR; @@ -422,6 +421,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module) s = talloc_asprintf(msg, "%llu", ltdb->sequence_number+1); if (!s) { + talloc_free(msg); errno = ENOMEM; return LDB_ERR_OPERATIONS_ERROR; } @@ -458,6 +458,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module) s = ldb_timestring(msg, t); if (s == NULL) { + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index db49455..71cffb9 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -179,6 +179,7 @@ normal_index: ret = ltdb_search_dn1(module, dn, msg); if (ret != LDB_SUCCESS) { + talloc_free(msg); return ret; } @@ -217,15 +218,13 @@ static int ltdb_dn_list_store_full(struct ldb_module *module, struct ldb_dn *dn, msg = ldb_msg_new(module); if (!msg) { - ldb_module_oom(module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = ldb_msg_add_fmt(msg, LTDB_IDXVERSION, "%u", LTDB_INDEXING_VERSION); if (ret != LDB_SUCCESS) { talloc_free(msg); - ldb_module_oom(module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } msg->dn = dn; @@ -234,9 +233,8 @@ static int ltdb_dn_list_store_full(struct ldb_module *module, struct ldb_dn *dn, ret = ldb_msg_add_empty(msg, LTDB_IDX, LDB_FLAG_MOD_ADD, &el); if (ret != LDB_SUCCESS) { - ldb_module_oom(module); talloc_free(msg); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } el->values = list->dn; el->num_values = list->count; @@ -347,13 +345,13 @@ int ltdb_index_transaction_commit(struct ldb_module *module) struct ldb_context *ldb = ldb_module_get_ctx(module); ldb_reset_err_string(ldb); + if (ltdb->idxptr->itdb) { tdb_traverse(ltdb->idxptr->itdb, ltdb_index_traverse_store, module); tdb_close(ltdb->idxptr->itdb); } ret = ltdb->idxptr->error; - if (ret != LDB_SUCCESS) { if (!ldb_errstring(ldb)) { ldb_set_errstring(ldb, ldb_strerror(ret)); @@ -415,7 +413,10 @@ static struct ldb_dn *ltdb_index_key(struct ldb_context *ldb, } if (ldb_should_b64_encode(ldb, &v)) { char *vstr = ldb_base64_encode(ldb, (char *)v.data, v.length); - if (!vstr) return NULL; + if (!vstr) { + talloc_free(attr_folded); + return NULL; + } ret = ldb_dn_new_fmt(ldb, ldb, "%s:%s::%s", LTDB_INDEX, attr_folded, vstr); talloc_free(vstr); } else { @@ -774,8 +775,7 @@ static int ltdb_index_dn_and(struct ldb_module *module, list2 = talloc_zero(list, struct dn_list); if (list2 == NULL) { - ldb_module_oom(module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(module); } ret = ltdb_index_dn(module, subtree, index_list, list2); @@ -966,6 +966,7 @@ static int ltdb_index_filter(const struct dn_list *dn_list, ret = ldb_module_send_entry(ac->req, msg, NULL); if (ret != LDB_SUCCESS) { + talloc_free(msg); ac->request_terminated = true; return ret; } @@ -1023,23 +1024,20 @@ int ltdb_search_indexed(struct ltdb_context *ac, uint32_t *match_count) dn_list = talloc_zero(ac, struct dn_list); if (dn_list == NULL) { - ldb_module_oom(ac->module); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(ac->module); } switch (ac->scope) { case LDB_SCOPE_BASE: dn_list->dn = talloc_array(dn_list, struct ldb_val, 1); if (dn_list->dn == NULL) { - ldb_module_oom(ac->module); talloc_free(dn_list); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(ac->module); } dn_list->dn[0].data = discard_const_p(unsigned char, ldb_dn_get_linearized(ac->base)); if (dn_list->dn[0].data == NULL) { - ldb_module_oom(ac->module); talloc_free(dn_list); - return LDB_ERR_OPERATIONS_ERROR; + return ldb_module_oom(ac->module); } dn_list->dn[0].length = strlen((char *)dn_list->dn[0].data); dn_list->count = 1; diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c index e7aeb47..396b80a 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_pack.c +++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c @@ -208,7 +208,6 @@ int ltdb_unpack_data(struct ldb_module *module, } if (message->num_elements == 0) { - message->elements = NULL; return 0; } diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index 1637c66..25ec1b0 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -373,7 +373,7 @@ static int ltdb_delete_internal(struct ldb_module *module, struct ldb_dn *dn) struct ldb_message *msg; int ret = LDB_SUCCESS; - msg = talloc(module, struct ldb_message); + msg = ldb_msg_new(module); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -629,7 +629,7 @@ int ltdb_modify_internal(struct ldb_module *module, return ltdb_err_map(tdb_error(ltdb->tdb)); } - msg2 = talloc(tdb_key.dptr, struct ldb_message); + msg2 = ldb_msg_new(tdb_key.dptr); if (msg2 == NULL) { free(tdb_data.dptr); ret = LDB_ERR_OTHER; @@ -912,7 +912,7 @@ static int ltdb_rename(struct ltdb_context *ctx) return LDB_ERR_OPERATIONS_ERROR; } - msg = talloc(ctx, struct ldb_message); + msg = ldb_msg_new(ctx); if (msg == NULL) { return LDB_ERR_OPERATIONS_ERROR; } @@ -1070,7 +1070,7 @@ static int ltdb_sequence_number(struct ltdb_context *ctx, dn = ldb_dn_new(tmp_ctx, ldb, LTDB_BASEINFO); - msg = talloc(tmp_ctx, struct ldb_message); + msg = ldb_msg_new(tmp_ctx); if (msg == NULL) { ret = LDB_ERR_OPERATIONS_ERROR; goto done; -- Samba Shared Repository