From c62eeda7718e4c15e19ade68455826ab32438f98 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 20 Jun 2012 13:34:11 +0200 Subject: libgf_client_chdir: don't access path[-1] upon chdir("") Admittedly, this code may not be reachable via glusterfs_chdir, assuming libgf_client_path_lookup with such a loc.path would fail. Change-Id: I0b72ade0918da30d49bff756dcf04d1512d0177f BUG: 789278 Signed-off-by: Jim Meyering Reviewed-on: http://review.gluster.com/3601 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfsclient/src/libglusterfsclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libglusterfsclient') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 3143a13ed..3881ad642 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -7806,7 +7806,7 @@ libgf_client_chdir (const char *path) { if (!libgf_path_absolute (path)) { resulting_cwd_len = strlen (path) + strlen (cwd) - + ((path[strlen (path) - 1] == '/') + + ((strlen (path) && path[strlen (path) - 1] == '/') ? 0 : 1) + 1; if (resulting_cwd_len > PATH_MAX) { -- cgit