You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Vlad Georgescu <vg...@gmail.com> on 2006/11/26 21:02:47 UTC

[PATCH] Bug in svn_repos_find_root_path on Windows?

Hi,

It seems that, on Windows, svn_repos_find_root_path will get stuck in
an infinite loop if it is given an absolute path that doesn't actually
contain a repository root. I discovered this after mistyping the root
path when invoking svnserve. The relevant code is this:

  while (1)
    {
      /* Try to decode the path, so we don't fail if it contains characters
         that aren't supported by the OS filesystem.  The subversion fs
         isn't restricted by the OS filesystem character set. */
      err = svn_utf_cstring_from_utf8(&decoded, candidate, pool);
      if (!err && check_repos_path(candidate, pool))
        break;
      svn_error_clear(err);
      if (candidate[0] == '\0' || strcmp(candidate, "/") == 0)
        return NULL;
      candidate = svn_path_dirname(candidate, pool);
    }

Notice that it only gets out of the loop when it encounters the Unix
root directory. The following patch fixes this problem:

[[[
* subversion/libsvn_repos/repos.c
  (svn_repos_find_root_path): Check that we reached the filesystem
root in a cross-platform
   manner.
]]]

Index: subversion/libsvn_repos/repos.c
===================================================================
--- subversion/libsvn_repos/repos.c	(revision 22436)
+++ subversion/libsvn_repos/repos.c	(working copy)
@@ -1851,7 +1851,8 @@
       if (!err && check_repos_path(candidate, pool))
         break;
       svn_error_clear(err);
-      if (candidate[0] == '\0' || strcmp(candidate, "/") == 0)
+      if (candidate[0] == '\0'
+          || svn_path_is_root(candidate, strlen(candidate), pool))
         return NULL;
       candidate = svn_path_dirname(candidate, pool);
     }

-- 
Vlad

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] Bug in svn_repos_find_root_path on Windows?

Posted by Daniel Rall <dl...@collab.net>.
On Tue, 28 Nov 2006, Vlad Georgescu wrote:

> On 11/28/06, Daniel Rall <dl...@collab.net> wrote:
> >On Sun, 26 Nov 2006, Vlad Georgescu wrote:
> >...
> >> It seems that, on Windows, svn_repos_find_root_path will get stuck in
> >> an infinite loop if it is given an absolute path that doesn't actually
> >> contain a repository root. I discovered this after mistyping the root
> >> path when invoking svnserve. The relevant code is this:
> >>
> >>  while (1)
> >>    {
> >>      /* Try to decode the path, so we don't fail if it contains 
> >characters
> >>         that aren't supported by the OS filesystem.  The subversion fs
> >>         isn't restricted by the OS filesystem character set. */
> >>      err = svn_utf_cstring_from_utf8(&decoded, candidate, pool);
> >>      if (!err && check_repos_path(candidate, pool))
> >>        break;
> >>      svn_error_clear(err);
> >>      if (candidate[0] == '\0' || strcmp(candidate, "/") == 0)
> >>        return NULL;
> >>      candidate = svn_path_dirname(candidate, pool);
> >>    }
> >>
> >> Notice that it only gets out of the loop when it encounters the Unix
> >> root directory. The following patch fixes this problem:
> >>
> >> [[[
> >> * subversion/libsvn_repos/repos.c
> >>  (svn_repos_find_root_path): Check that we reached the filesystem
> >> root in a cross-platform
> >>   manner.
> >> ]]]
> >
> >Thanks Vlad, committed in r22483.
> 
> On a related note, shouldn't svnserve check the validity of the --root
> argument? That's how I ran into this problem in the first place.

Sounds good to me.  If no one thinks different, do you mind putting
together a patch?

- Dan

Re: [PATCH] Bug in svn_repos_find_root_path on Windows?

Posted by Vlad Georgescu <vg...@gmail.com>.
On 11/28/06, Daniel Rall <dl...@collab.net> wrote:
> On Sun, 26 Nov 2006, Vlad Georgescu wrote:
> ...
> > It seems that, on Windows, svn_repos_find_root_path will get stuck in
> > an infinite loop if it is given an absolute path that doesn't actually
> > contain a repository root. I discovered this after mistyping the root
> > path when invoking svnserve. The relevant code is this:
> >
> >  while (1)
> >    {
> >      /* Try to decode the path, so we don't fail if it contains characters
> >         that aren't supported by the OS filesystem.  The subversion fs
> >         isn't restricted by the OS filesystem character set. */
> >      err = svn_utf_cstring_from_utf8(&decoded, candidate, pool);
> >      if (!err && check_repos_path(candidate, pool))
> >        break;
> >      svn_error_clear(err);
> >      if (candidate[0] == '\0' || strcmp(candidate, "/") == 0)
> >        return NULL;
> >      candidate = svn_path_dirname(candidate, pool);
> >    }
> >
> > Notice that it only gets out of the loop when it encounters the Unix
> > root directory. The following patch fixes this problem:
> >
> > [[[
> > * subversion/libsvn_repos/repos.c
> >  (svn_repos_find_root_path): Check that we reached the filesystem
> > root in a cross-platform
> >   manner.
> > ]]]
>
> Thanks Vlad, committed in r22483.

On a related note, shouldn't svnserve check the validity of the --root
argument? That's how I ran into this problem in the first place.

-- 
Vlad

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] Bug in svn_repos_find_root_path on Windows?

Posted by Daniel Rall <dl...@collab.net>.
On Sun, 26 Nov 2006, Vlad Georgescu wrote:
...
> It seems that, on Windows, svn_repos_find_root_path will get stuck in
> an infinite loop if it is given an absolute path that doesn't actually
> contain a repository root. I discovered this after mistyping the root
> path when invoking svnserve. The relevant code is this:
> 
>  while (1)
>    {
>      /* Try to decode the path, so we don't fail if it contains characters
>         that aren't supported by the OS filesystem.  The subversion fs
>         isn't restricted by the OS filesystem character set. */
>      err = svn_utf_cstring_from_utf8(&decoded, candidate, pool);
>      if (!err && check_repos_path(candidate, pool))
>        break;
>      svn_error_clear(err);
>      if (candidate[0] == '\0' || strcmp(candidate, "/") == 0)
>        return NULL;
>      candidate = svn_path_dirname(candidate, pool);
>    }
> 
> Notice that it only gets out of the loop when it encounters the Unix
> root directory. The following patch fixes this problem:
> 
> [[[
> * subversion/libsvn_repos/repos.c
>  (svn_repos_find_root_path): Check that we reached the filesystem
> root in a cross-platform
>   manner.
> ]]]

Thanks Vlad, committed in r22483.