From ccee8039720f8253d460384aa6659edd8e75f3db Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Fri, 18 Feb 2011 00:06:26 +0000 Subject: Fix getcwd size arg to make it work in solaris. glusterfs/d -f path failed if the path was not absolute. If the BUF argument is NULL, then on solaris the size argument has to be passed. On linux, if the size argument passed is 0, then it dynmically allocates a buffer of the required size. The fix is to pass PATH_MAX as the size for consistency. Signed-off-by: Shishir Gowda Signed-off-by: Anand V. Avati BUG: 2443 (starting glusterfs/d -f with relative path crashes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2443 --- glusterfsd/src/glusterfsd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'glusterfsd') diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c index 4977e2b72..87d16c7dc 100644 --- a/glusterfsd/src/glusterfsd.c +++ b/glusterfsd/src/glusterfsd.c @@ -469,7 +469,13 @@ parse_opts (int key, char *arg, struct argp_state *state) GF_FREE (cmd_args->volfile); if (arg[0] != '/') { - pwd = getcwd (NULL, 0); + pwd = getcwd (NULL, PATH_MAX); + if (!pwd) { + argp_failure (state, -1, errno, + "getcwd failed with error no %d", + errno); + break; + } snprintf (tmp_buf, 1024, "%s/%s", pwd, arg); cmd_args->volfile = gf_strdup (tmp_buf); free (pwd); -- cgit