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

Re: [PATCH] locks fix in BDB

From: Julian Foad <julian.foad_at_wandisco.com>
Date: Tue, 20 Sep 2011 15:37:08 +0100

On Tue, 2011-09-20 at 17:19 +0300, Daniel Shahaf wrote:
> I found it while reading the code; I don't know of a real-world bug that
> this fixes. I suppose it fixes the locks check if someone calls, say,
> svn_fs_change_node_prop() with a PATH argument that doesn't have
> a leading slash [1], but I admit I haven't tested that.
>
> (The more-obvious code path, svn_fs_get_locks(), does canonicalize PATH,
> causing it to get a leading slash, before passing it to lower-level code.)

It looks like this code is adding a *trailing* slash, not a leading one.

- Julian

> Julian Foad wrote on Tue, Sep 20, 2011 at 15:03:31 +0100:
> > What does this fix?
> >
> > - Julian
> >
> >
> > On Tue, 2011-09-20 at 16:25 +0300, Daniel Shahaf wrote:
> > > Does this look correct? locks-test and lock_tests.py both pass.
> > >
> > > [[[
> > > * subversion/libsvn_fs_base/bdb/locks-table.c
> > > (svn_fs_bdb__locks_get):
> > > Set LOOKUP_PATH before constructing BDB's KEY from it.
> > > ]]]
> > >
> > > [[[
> > > Index: subversion/libsvn_fs_base/bdb/locks-table.c
> > > ===================================================================
> > > --- subversion/libsvn_fs_base/bdb/locks-table.c (revision 1173129)
> > > +++ subversion/libsvn_fs_base/bdb/locks-table.c (working copy)
> > > @@ -206,7 +206,7 @@ svn_fs_bdb__locks_get(svn_fs_t *fs,
> > > const char *lock_token;
> > > svn_lock_t *lock;
> > > svn_error_t *err;
> > > - const char *lookup_path = path;
> > > + const char *lookup_path;
> > >
> > > /* First, try to lookup PATH itself. */
> > > err = svn_fs_bdb__lock_token_get(&lock_token, fs, path, trail, pool);
> > > @@ -238,6 +238,11 @@ svn_fs_bdb__locks_get(svn_fs_t *fs,
> > > &cursor, 0);
> > > SVN_ERR(BDB_WRAP(fs, "creating cursor for reading lock tokens", db_err));
> > >
> > > + if (!svn_fspath__is_root(path, strlen(path)))
> > > + lookup_path = apr_pstrcat(pool, path, "/", (char *)NULL);
> > > + else
> > > + lookup_path = path;
> > > +
> > > /* Since the key is going to be returned as well as the value make
> > > sure BDB malloc's the returned key. */
> > > svn_fs_base__str_to_dbt(&key, lookup_path);
> > > @@ -247,9 +252,6 @@ svn_fs_bdb__locks_get(svn_fs_t *fs,
> > > the one passed in, by passing in the DB_RANGE_SET flag. */
> > > db_err = svn_bdb_dbc_get(cursor, &key, svn_fs_base__result_dbt(&value),
> > > DB_SET_RANGE);
> > > -
> > > - if (!svn_fspath__is_root(path, strlen(path)))
> > > - lookup_path = apr_pstrcat(pool, path, "/", (char *)NULL);
> > >
> > > /* As long as the prefix of the returned KEY matches LOOKUP_PATH we
> > > know it is either LOOKUP_PATH or a decendant thereof. */
> > > ]]]
> >
> >
Received on 2011-09-20 16:37:47 CEST

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