From 4a505c0eb8736d75a677530a7789fc9bc03d4c28 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 20 Jun 2012 11:33:10 +0200 Subject: gsyncd: don't let a bogus config file make us read/write buf[-1] Change-Id: Ic55c28c572c1878f8a223ae2fd25d301a7ef0c12 BUG: 789278 Signed-off-by: Jim Meyering Reviewed-on: http://review.gluster.com/3596 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/features/marker/utils/src/gsyncd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xlators/features/marker/utils/src/gsyncd.c b/xlators/features/marker/utils/src/gsyncd.c index 7da2c983c..487eea1e5 100644 --- a/xlators/features/marker/utils/src/gsyncd.c +++ b/xlators/features/marker/utils/src/gsyncd.c @@ -107,6 +107,7 @@ invoke_gsyncd (int argc, char **argv) char *nargv[argc + 4]; if (restricted) { + size_t len; /* in restricted mode we forcibly use the system-wide config */ runinit (&runner); runner_add_args (&runner, SBIN_DIR"/gluster", @@ -116,9 +117,10 @@ invoke_gsyncd (int argc, char **argv) if (runner_start (&runner) == 0 && fgets (config_file, PATH_MAX, runner_chio (&runner, STDOUT_FILENO)) != NULL && - config_file[strlen (config_file) - 1] == '\n' && + (len = strlen (config_file)) && + config_file[len - 1] == '\n' && runner_end (&runner) == 0) - gluster_workdir_len = strlen (config_file) - 1; + gluster_workdir_len = len - 1; if (gluster_workdir_len) { if (gluster_workdir_len + 1 + strlen (GSYNCD_CONF) + 1 > -- cgit