[SCM] Samba Shared Repository - branch master updated

Kamen Mazdrashki kamenim at samba.org
Wed Dec 1 03:46:01 MST 2010


The branch, master has been updated
       via  4cd16dd s4-ranged_result.c: Fix memory context for ranged attributes handling
      from  6e27ff3 s3 docs: Reword posix locking text to answer a common question

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4cd16dde148662700311501e62ba3ee9bf80765a
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Wed Dec 1 11:04:19 2010 +0200

    s4-ranged_result.c: Fix memory context for ranged attributes handling
    
    Pair-Programmed-With: Zahari Zahariev <zahari.zahariev at postpath.com>
    
    Autobuild-User: Kamen Mazdrashki <kamenim at samba.org>
    Autobuild-Date: Wed Dec  1 11:45:48 CET 2010 on sn-devel-104

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/samdb/ldb_modules/ranged_results.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/samdb/ldb_modules/ranged_results.c b/source4/dsdb/samdb/ldb_modules/ranged_results.c
index b3e79d0..f8e8db6 100644
--- a/source4/dsdb/samdb/ldb_modules/ranged_results.c
+++ b/source4/dsdb/samdb/ldb_modules/ranged_results.c
@@ -59,6 +59,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 	struct ldb_context *ldb;
 	struct rr_context *ac;
 	unsigned int i, j;
+	TALLOC_CTX *temp_ctx;
 
 	ac = talloc_get_type(req->context, struct rr_context);
 	ldb = ldb_module_get_ctx(ac->module);
@@ -83,6 +84,13 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 
 	/* LDB_REPLY_ENTRY */
 
+	temp_ctx = talloc_new(ac->req);
+	if (!temp_ctx) {
+		ldb_module_oom(ac->module);
+		return ldb_module_done(ac->req, NULL, NULL,
+				       LDB_ERR_OPERATIONS_ERROR);
+	}
+
 	/* Find those that are range requests from the attribute list */
 	for (i = 0; ac->req->op.search.attrs[i]; i++) {
 		char *p, *new_attr;
@@ -90,6 +98,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 		unsigned int start, end, orig_num_values;
 		struct ldb_message_element *el;
 		struct ldb_val *orig_values;
+
 		p = strchr(ac->req->op.search.attrs[i], ';');
 		if (!p) {
 			continue;
@@ -104,7 +113,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 				continue;
 			}
 		}
-		new_attr = talloc_strndup(ac->req,
+		new_attr = talloc_strndup(temp_ctx,
 					  ac->req->op.search.attrs[i],
 					  (size_t)(p - ac->req->op.search.attrs[i]));
 
@@ -124,7 +133,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 			end_str = "*";
 			end = el->num_values - 1;
 		} else {
-			end_str = talloc_asprintf(el, "%u", end);
+			end_str = talloc_asprintf(temp_ctx, "%u", end);
 			if (!end_str) {
 				ldb_oom(ldb);
 				return ldb_module_done(ac->req, NULL, NULL,
@@ -148,7 +157,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 			
 			el->num_values = 0;
 			
-			el->values = talloc_array(el, struct ldb_val, (end - start) + 1);
+			el->values = talloc_array(ares->message->elements, struct ldb_val, (end - start) + 1);
 			if (!el->values) {
 				ldb_oom(ldb);
 				return ldb_module_done(ac->req, NULL, NULL,
@@ -159,7 +168,7 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 				el->num_values++;
 			}
 		}
-		el->name = talloc_asprintf(el, "%s;range=%u-%s", el->name, start, end_str);
+		el->name = talloc_asprintf(el->values, "%s;range=%u-%s", el->name, start, end_str);
 		if (!el->name) {
 			ldb_oom(ldb);
 			return ldb_module_done(ac->req, NULL, NULL,
@@ -167,6 +176,8 @@ static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
 		}
 	}
 
+	talloc_free(temp_ctx);
+
 	return ldb_module_send_entry(ac->req, ares->message, ares->controls);
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list