From 5e59de561e49e8f401cf0786635c05c31cc3dfb8 Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Thu, 21 Apr 2011 06:55:46 +0000 Subject: mgmt/glusterd: fix up the buffer sizes to accomodate a correct estimate of sizes of the snprintf invocations, and errout if not feasible Signed-off-by: Kaushik BV Signed-off-by: Anand Avati BUG: 2561 (gsyncd command's must be preconfigured) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2561 --- cli/src/cli-cmd-misc.c | 2 +- cli/src/cli-cmd-volume.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-cmd-misc.c b/cli/src/cli-cmd-misc.c index 55825f6993b..356118e19e9 100644 --- a/cli/src/cli-cmd-misc.c +++ b/cli/src/cli-cmd-misc.c @@ -59,7 +59,7 @@ cli_cmd_display_help (struct cli_state *state, struct cli_cmd_word *in_word, struct cli_cmd *cmd_ind = NULL; int i = 0; - /* cli_systerm_cmds commands for internal usage + /* cli_system_cmds commands for internal usage they are not exposed */ for (i=0; cmd[i]!=NULL; i++) diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index bb549589be6..673202440fc 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1066,13 +1066,16 @@ cli_check_gsync_present () } ret = snprintf (cmd, sizeof(cmd), GSYNCD_PREFIX "/gsyncd"); - if (ret < 0) - return 0; + if (ret < 0) { + ret = 0; + goto out; + } ret = lstat (cmd, &stat_buff); if (ret || !(stat_buff.st_mode & S_IXUSR)) { + ret = -1; gf_log ("", GF_LOG_INFO, "geo-replication not installed"); - return -1; + goto out; } ret = setenv ("_GLUSTERD_CALLED_", "1", 1); @@ -1086,14 +1089,21 @@ cli_check_gsync_present () ret = snprintf (cmd, sizeof(cmd), GSYNCD_PREFIX"/gsyncd --version"); if (!(in = popen(cmd, "r"))) { + ret = -1; gf_log ("", GF_LOG_INFO, "geo-replication not installed"); - return -1; + goto out; } ptr = fgets(buff, sizeof(buff), in); - if (ptr) - if (!strstr (buff, "gsyncd")) - return -1; + if (ptr) { + if (!strstr (buff, "gsyncd")) { + ret = -1; + goto out; + } + } else { + ret = -1; + goto out; + } ret = pclose (in); -- cgit