From: Matthias Dieter Wallnöfer Date: Fri, 14 Jan 2011 11:48:54 +0000 (+0100) Subject: ldb:ldbedit tool - fix bug #7914 X-Git-Tag: tevent-0.9.11~822 X-Git-Url: http://git.samba.org/samba.git/?p=samba.git;a=commitdiff_plain;h=79d3532f7f905afe1a48acabf75247cef6f791e3 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). --- 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; } /*