summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2009-09-01 00:32:40 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-08 03:23:36 -0700
commitc0c54cd9feeff6093c78027fade26379838e9899 (patch)
tree1840450bddf4b41955b45a5cc9ca7b72c4d098cd /libglusterfsclient
parent7b3cad9869118386afd8b5f13ab2cff5d6190b7b (diff)
libglusterfsclient: handle paths terminating with '/' properly in libgf_trim_to_prev_dir.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 236 (Stack overflow due to infinite recursion in glusterfs_glh_realpath) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=236
Diffstat (limited to 'libglusterfsclient')
-rwxr-xr-xlibglusterfsclient/src/libglusterfsclient.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c
index f3a7e3a0d..58a8017d3 100755
--- a/libglusterfsclient/src/libglusterfsclient.c
+++ b/libglusterfsclient/src/libglusterfsclient.c
@@ -709,6 +709,7 @@ char *
libgf_trim_to_prev_dir (char * path)
{
char *idx = NULL;
+ int len = 0;
if (!path)
return NULL;
@@ -716,9 +717,14 @@ libgf_trim_to_prev_dir (char * path)
/* Check if we're already at root, if yes
* then there is no prev dir.
*/
- if (strlen (path) == 1)
+ len = strlen (path);
+ if (len == 1)
return path;
+ if (path[len - 1] == '/') {
+ path[len - 1] = '\0';
+ }
+
idx = libgf_rrindex (path, '/', 1);
/* Move to the char after the / */
++idx;