From: Andrej Gessel Date: Thu, 14 Jun 2018 10:19:29 +0000 (+0200) Subject: Fix several mem leaks in ldb_index ldb_search ldb_tdb X-Git-Tag: tevent-0.9.37~331 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ca1c09f686fbfa9257cd95710dba4a98c3eeb8f;p=thirdparty%2Fsamba.git Fix several mem leaks in ldb_index ldb_search ldb_tdb BUG: https://bugzilla.samba.org/show_bug.cgi?id=13475 Signed-off-by: Andrej Gessel Reviewed-by: Jeremy Allison Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Fri Jun 15 23:07:25 CEST 2018 on sn-devel-144 --- diff --git a/lib/ldb/ldb_tdb/ldb_index.c b/lib/ldb/ldb_tdb/ldb_index.c index 04ffbad65cd..d59b4b16290 100644 --- a/lib/ldb/ldb_tdb/ldb_index.c +++ b/lib/ldb/ldb_tdb/ldb_index.c @@ -416,6 +416,7 @@ normal_index: "expected %d for %s", version, LTDB_INDEXING_VERSION, ldb_dn_get_linearized(dn)); + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } @@ -433,14 +434,17 @@ normal_index: "expected %d for %s", version, LTDB_GUID_INDEXING_VERSION, ldb_dn_get_linearized(dn)); + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } if (el->num_values == 0) { + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } if ((el->values[0].length % LTDB_GUID_SIZE) != 0) { + talloc_free(msg); return LDB_ERR_OPERATIONS_ERROR; } @@ -521,6 +525,7 @@ int ltdb_key_dn_from_idx(struct ldb_module *module, const int flags = LDB_UNPACK_DATA_FLAG_NO_ATTRS; struct ldb_message *rec = ldb_msg_new(ldb); if (rec == NULL) { + TALLOC_FREE(list); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c index cfc37149399..18f84056e66 100644 --- a/lib/ldb/ldb_tdb/ldb_search.c +++ b/lib/ldb/ldb_tdb/ldb_search.c @@ -397,7 +397,7 @@ int ltdb_filter_attrs(TALLOC_CTX *mem_ctx, /* Shortcuts for the simple cases */ } else if (add_dn && i == 1) { if (msg_add_distinguished_name(msg2) != 0) { - return -1; + goto failed; } *filtered_msg = msg2; return 0; @@ -463,7 +463,7 @@ int ltdb_filter_attrs(TALLOC_CTX *mem_ctx, if (add_dn) { if (msg_add_distinguished_name(msg2) != 0) { - return -1; + goto failed; } } @@ -472,7 +472,7 @@ int ltdb_filter_attrs(TALLOC_CTX *mem_ctx, struct ldb_message_element, msg2->num_elements); if (msg2->elements == NULL) { - return -1; + goto failed; } } else { talloc_free(msg2->elements); @@ -483,6 +483,7 @@ int ltdb_filter_attrs(TALLOC_CTX *mem_ctx, return 0; failed: + TALLOC_FREE(msg2); return -1; } diff --git a/lib/ldb/ldb_tdb/ldb_tdb.c b/lib/ldb/ldb_tdb/ldb_tdb.c index 51d608723e8..daf9a778f5b 100644 --- a/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/lib/ldb/ldb_tdb/ldb_tdb.c @@ -485,6 +485,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg } if (ltdb->read_only) { + talloc_free(tdb_key_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; } @@ -732,6 +733,7 @@ int ltdb_delete_noindex(struct ldb_module *module, } if (ltdb->read_only) { + talloc_free(tdb_key_ctx); return LDB_ERR_UNWILLING_TO_PERFORM; }