cluster: STABLE3 - libfence: increase FENCE_AGENT_ARGS_MAX to 4096

David Teigland teigland at fedoraproject.org
Mon Oct 12 16:48:19 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b2230a5adff95b1db62deb9acfbf0f37553101b9
Commit:        b2230a5adff95b1db62deb9acfbf0f37553101b9
Parent:        65c092ae930b3ac8589406812d57204998ae46d0
Author:        David Teigland <teigland at redhat.com>
AuthorDate:    Mon Oct 12 11:38:28 2009 -0500
Committer:     David Teigland <teigland at redhat.com>
CommitterDate: Mon Oct 12 11:38:28 2009 -0500

libfence: increase FENCE_AGENT_ARGS_MAX to 4096

The previous limit of 1024 may be a bit small in some cases.

Also fix and clean up the handling of terminating \0 in the
agent and args strings.  The MAX values now include space
for the terminating \0, and snprintfs are responsible for
ensuring a \0.

(Have tested and verified that the fence_log struct size change
does not cause compatibility problems.)

Signed-off-by: David Teigland <teigland at redhat.com>
---
 fence/libfence/agent.c    |    6 +++---
 fence/libfence/libfence.h |    8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fence/libfence/agent.c b/fence/libfence/agent.c
index a4b30e8..4c19f10 100644
--- a/fence/libfence/agent.c
+++ b/fence/libfence/agent.c
@@ -262,7 +262,7 @@ static int use_device(int cd, char *victim, char *method, int d,
 		goto out;
 	}
 
-	strncpy(lp->agent_name, agent, FENCE_AGENT_NAME_MAX);
+	strncpy(lp->agent_name, agent, FENCE_AGENT_NAME_MAX-1);
 
 	error = make_args(cd, victim, method, d, device, &args);
 	if (error) {
@@ -270,7 +270,7 @@ static int use_device(int cd, char *victim, char *method, int d,
 		goto out_agent;
 	}
 
-	strncpy(lp->agent_args, args, FENCE_AGENT_ARGS_MAX);
+	strncpy(lp->agent_args, args, FENCE_AGENT_ARGS_MAX-1);
 
 	error = run_agent(agent, args, &lp->error);
 
@@ -529,7 +529,7 @@ static int use_device_unfence(int cd, char *victim, int d,
 		goto out;
 	}
 
-	strncpy(lp->agent_name, agent, FENCE_AGENT_NAME_MAX);
+	strncpy(lp->agent_name, agent, FENCE_AGENT_NAME_MAX-1);
 
 	error = make_args_unfence(cd, victim, d, device, &args);
 	if (error) {
diff --git a/fence/libfence/libfence.h b/fence/libfence/libfence.h
index e3d2148..33f493a 100644
--- a/fence/libfence/libfence.h
+++ b/fence/libfence/libfence.h
@@ -16,15 +16,15 @@ extern "C" {
 #define FE_READ_METHOD		9	/* read (ccs) error on method */
 #define FE_READ_DEVICE		10	/* read (ccs) error on method/device */
 
-#define FENCE_AGENT_NAME_MAX 256
-#define FENCE_AGENT_ARGS_MAX 1024
+#define FENCE_AGENT_NAME_MAX 256	/* including terminating \0 */
+#define FENCE_AGENT_ARGS_MAX 4096	/* including terminating \0 */
 
 struct fence_log {
 	int error;
 	int method_num;
 	int device_num;
-	char agent_name[FENCE_AGENT_NAME_MAX+1];
-	char agent_args[FENCE_AGENT_ARGS_MAX+1];
+	char agent_name[FENCE_AGENT_NAME_MAX];
+	char agent_args[FENCE_AGENT_ARGS_MAX];
 };
 
 int fence_node(char *name, struct fence_log *log, int log_size, int *log_count);


More information about the cluster-commits mailing list