fence: master - libfence: increase FENCE_AGENT_ARGS_MAX to 4096

David Teigland teigland at fedoraproject.org
Mon Oct 12 19:24:08 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/fence.git?p=fence.git;a=commitdiff;h=d3d58caa28d779c76b6034a5d2abfe6d6ab368dd
Commit:        d3d58caa28d779c76b6034a5d2abfe6d6ab368dd
Parent:        f4a59315a43bfac94f58493feaeea9680c05b5d7
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 14:23:53 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 0749a52..adf12b1 100644
--- a/fence/libfence/agent.c
+++ b/fence/libfence/agent.c
@@ -264,7 +264,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) {
@@ -272,7 +272,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);
 
@@ -531,7 +531,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