[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] svn_path_canonicalize updated

From: Greg Stein <gstein_at_lyra.org>
Date: 2001-09-20 08:13:47 CEST

On Wed, Sep 19, 2001 at 10:39:45PM -0400, Garrett Rooney wrote:
>...
> --- subversion/clients/cmdline/SVN/text-base/util.c Mon Sep 10 23:07:52 2001
> +++ subversion/clients/cmdline/util.c Wed Sep 19 21:05:13 2001
> @@ -158,7 +158,6 @@
> svn_stringbuf_t *target = svn_stringbuf_create (os->argv[os->ind], pool);
> svn_stringbuf_t *basename;
>
> - svn_path_canonicalize (target, svn_path_local_style);
> basename = svn_path_last_component (target, svn_path_local_style, pool);

There are probably some repercussions from doing this. Note that the next
call is to svn_path_last_component(). That function may fail if passed a
non-canonical path.

Also note that it uses svn_path_local_style, too. IOW, it will be just as
broken as the call to the canonicalize. Somebody needs to get in there and
do some real review and fixing.

>...
> --- subversion/libsvn_subr/SVN/text-base/path.c Tue Sep 18 17:38:56 2001
> +++ subversion/libsvn_subr/path.c Wed Sep 19 20:55:17 2001
> @@ -74,11 +74,28 @@
> {
> char dirsep = get_separator_from_style (style);
>
> - /* At some point this could eliminiate redundant components.
> - For now, it just makes sure there is no trailing slash. */
> + char sep_sep[3] = { dirsep, dirsep, '\0' };
> + char sep_dot_sep[0] = { dirsep, '.', dirsep, '\0' };
>
> - /* kff todo: maybe should be implemented with a new routine in
> - libsvn_string. */
> + char *str = NULL, *tmp = NULL;
> +
> + if (style == svn_path_url_style || style == svn_path_repos_style) {
> + str = strstr (path->data, "//");

A relative URL with "//" present will throw this off.

>...
> + while ((tmp = strstr (str, sep_sep)) != NULL)
> + strcpy (tmp, tmp + 1);
> +
> + while ((tmp = strstr (str, sep_dot_sep)) != NULL)
> + strcpy (tmp, tmp + 2);

strcpy() is not guaranteed to work properly when the two strings overlap.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:42 2006

This is an archived mail posted to the Subversion Dev mailing list.