From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19879 invoked by alias); 7 Nov 2008 22:34:57 -0000 Received: (qmail 19858 invoked by alias); 7 Nov 2008 22:34:57 -0000 X-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_MX,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com X-Spam-Level: Subject: master - fence: Fix bug in make_args() To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 69b3ecac8da9ce4a34efb6702b253e52ea87e063 X-Git-Newrev: 3de140ad461dadfd99eadd4d37bc9d53ffd1b741 From: Lon Hohberger Message-Id: <20081107223350.BB72412036C@lists.fedorahosted.org> Date: Fri, 07 Nov 2008 22:34:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q4/txt/msg00265.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3de140ad461dadfd99eadd4d37bc9d53ffd1b741 Commit: 3de140ad461dadfd99eadd4d37bc9d53ffd1b741 Parent: 69b3ecac8da9ce4a34efb6702b253e52ea87e063 Author: Lon Hohberger AuthorDate: Fri Nov 7 17:33:20 2008 -0500 Committer: Lon Hohberger CommitterDate: Fri Nov 7 17:33:20 2008 -0500 fence: Fix bug in make_args() A bug in make_args() caused it to always return an error code, even if we formulated a perfectly good set of arguments. Basically, eventually ccs_get_list returns -1 when all items are exhausted, so the check at the bottom of the function would free any arguments we had (correctly) set up and return an error code, thereby avoiding actually calling the agent. --- fence/libfence/agent.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/fence/libfence/agent.c b/fence/libfence/agent.c index 3454ec7..c04df17 100644 --- a/fence/libfence/agent.c +++ b/fence/libfence/agent.c @@ -128,7 +128,7 @@ static int make_args(int cd, char *victim, char *method, int d, char *device, char **args_out) { char path[256], *args, *str; - int error; + int error, cnt = 0; args = malloc(MAX_AGENT_ARGS_LEN); if (!args) @@ -144,6 +144,7 @@ static int make_args(int cd, char *victim, char *method, int d, error = ccs_get_list(cd, path, &str); if (error || !str) break; + ++cnt; if (!strncmp(str, "name=", 5)) { free(str); @@ -164,6 +165,7 @@ static int make_args(int cd, char *victim, char *method, int d, error = ccs_get_list(cd, path, &str); if (error || !str) break; + ++cnt; if (!strncmp(str, "name=", 5)) { free(str); @@ -175,6 +177,8 @@ static int make_args(int cd, char *victim, char *method, int d, free(str); } + if (cnt) + error = 0; if (error) { free(args); args = NULL;