[PATCH 7/7] ldb:ldbedit tool - fix bug #7914

Matthias Dieter Wallnöfer mdw at samba.org
Mon Jan 17 14:45:32 MST 2011


"modify_record" returns "-1" when failing, otherwise the number of
modifies performed as an "unsigned int" converted to "int".
When we get "-1" we immediately need to stop (the error message has
already been generated by the function itself).
---
 source4/lib/ldb/tools/ldbedit.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 3db8b7e..3b3d37f 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -119,7 +119,7 @@ static int merge_edits(struct ldb_context *ldb,
 {
 	unsigned int i;
 	struct ldb_message *msg;
-	int ret = 0;
+	int ret;
 	unsigned int adds=0, modifies=0, deletes=0;
 	struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
 	if (options->controls != NULL && req_ctrls == NULL) {
@@ -148,8 +148,11 @@ static int merge_edits(struct ldb_context *ldb,
 			}
 			adds++;
 		} else {
-			if (modify_record(ldb, msg, msgs2[i], req_ctrls) > 0) {
-				modifies++;
+			ret = modify_record(ldb, msg, msgs2[i], req_ctrls);
+			if (ret != -1) {
+				modifies += (unsigned int) ret;
+			} else {
+				return -1;
 			}
 		}
 	}
@@ -179,7 +182,7 @@ static int merge_edits(struct ldb_context *ldb,
 
 	printf("# %u adds  %u modifies  %u deletes\n", adds, modifies, deletes);
 
-	return ret;
+	return 0;
 }
 
 /*
-- 
1.7.3.4



More information about the samba-technical mailing list