diff options
| author | Raghavendra G <raghavendra@gluster.com> | 2009-09-01 00:32:40 +0000 | 
|---|---|---|
| committer | Anand V. Avati <avati@dev.gluster.com> | 2009-09-08 03:23:36 -0700 | 
| commit | c0c54cd9feeff6093c78027fade26379838e9899 (patch) | |
| tree | 1840450bddf4b41955b45a5cc9ca7b72c4d098cd /libglusterfsclient | |
| parent | 7b3cad9869118386afd8b5f13ab2cff5d6190b7b (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-x | libglusterfsclient/src/libglusterfsclient.c | 8 | 
1 files changed, 7 insertions, 1 deletions
diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index f3a7e3a0dec..58a8017d347 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;  | 
