From 79d3532f7f905afe1a48acabf75247cef6f791e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Matthias=20Dieter=20Walln=C3=B6fer?= Date: Fri, 14 Jan 2011 12:48:54 +0100 Subject: [PATCH] ldb:ldbedit tool - fix bug #7914 "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 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c index 5b8beb662dd..ecdb4d7f621 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; } /* -- 2.34.1