|
|
720190 |
# ./pullrev.sh 1692801 1694012
|
|
|
720190 |
|
|
|
720190 |
https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2015-3187
|
|
|
720190 |
|
|
|
720190 |
http://svn.apache.org/viewvc?view=revision&revision=1692801
|
|
|
720190 |
|
|
|
720190 |
- excluding changes from CVE-2015-3184
|
|
|
720190 |
|
|
|
720190 |
diff -uap subversion-1.7.14/subversion/libsvn_repos/rev_hunt.c.cve3187 subversion-1.7.14/subversion/libsvn_repos/rev_hunt.c
|
|
|
720190 |
--- subversion-1.7.14/subversion/libsvn_repos/rev_hunt.c.cve3187
|
|
|
720190 |
+++ subversion-1.7.14/subversion/libsvn_repos/rev_hunt.c
|
|
|
720190 |
@@ -721,23 +721,6 @@ svn_repos_trace_node_locations(svn_fs_t
|
|
|
720190 |
if (! prev_path)
|
|
|
720190 |
break;
|
|
|
720190 |
|
|
|
720190 |
- if (authz_read_func)
|
|
|
720190 |
- {
|
|
|
720190 |
- svn_boolean_t readable;
|
|
|
720190 |
- svn_fs_root_t *tmp_root;
|
|
|
720190 |
-
|
|
|
720190 |
- SVN_ERR(svn_fs_revision_root(&tmp_root, fs, revision, currpool));
|
|
|
720190 |
- SVN_ERR(authz_read_func(&readable, tmp_root, path,
|
|
|
720190 |
- authz_read_baton, currpool));
|
|
|
720190 |
- if (! readable)
|
|
|
720190 |
- {
|
|
|
720190 |
- svn_pool_destroy(lastpool);
|
|
|
720190 |
- svn_pool_destroy(currpool);
|
|
|
720190 |
-
|
|
|
720190 |
- return SVN_NO_ERROR;
|
|
|
720190 |
- }
|
|
|
720190 |
- }
|
|
|
720190 |
-
|
|
|
720190 |
/* Assign the current path to all younger revisions until we reach
|
|
|
720190 |
the copy target rev. */
|
|
|
720190 |
while ((revision_ptr < revision_ptr_end)
|
|
|
720190 |
@@ -760,6 +743,20 @@ svn_repos_trace_node_locations(svn_fs_t
|
|
|
720190 |
path = prev_path;
|
|
|
720190 |
revision = prev_rev;
|
|
|
720190 |
|
|
|
720190 |
+ if (authz_read_func)
|
|
|
720190 |
+ {
|
|
|
720190 |
+ svn_boolean_t readable;
|
|
|
720190 |
+ SVN_ERR(svn_fs_revision_root(&root, fs, revision, currpool));
|
|
|
720190 |
+ SVN_ERR(authz_read_func(&readable, root, path,
|
|
|
720190 |
+ authz_read_baton, currpool));
|
|
|
720190 |
+ if (!readable)
|
|
|
720190 |
+ {
|
|
|
720190 |
+ svn_pool_destroy(lastpool);
|
|
|
720190 |
+ svn_pool_destroy(currpool);
|
|
|
720190 |
+ return SVN_NO_ERROR;
|
|
|
720190 |
+ }
|
|
|
720190 |
+ }
|
|
|
720190 |
+
|
|
|
720190 |
/* Clear last pool and switch. */
|
|
|
720190 |
svn_pool_clear(lastpool);
|
|
|
720190 |
tmppool = lastpool;
|
|
|
720190 |
diff -uap subversion-1.7.14/subversion/tests/cmdline/authz_tests.py.cve3187 subversion-1.7.14/subversion/tests/cmdline/authz_tests.py
|
|
|
720190 |
--- subversion-1.7.14/subversion/tests/cmdline/authz_tests.py.cve3187
|
|
|
720190 |
+++ subversion-1.7.14/subversion/tests/cmdline/authz_tests.py
|
|
|
720190 |
@@ -608,8 +608,10 @@ def authz_log_and_tracing_test(sbox):
|
|
|
720190 |
|
|
|
720190 |
## cat
|
|
|
720190 |
|
|
|
720190 |
+ expected_err2 = ".*svn: E195012: Unable to find repository location.*"
|
|
|
720190 |
+
|
|
|
720190 |
# now see if we can look at the older version of rho
|
|
|
720190 |
- svntest.actions.run_and_verify_svn(None, None, expected_err,
|
|
|
720190 |
+ svntest.actions.run_and_verify_svn(None, None, expected_err2,
|
|
|
720190 |
'cat', '-r', '2', D_url+'/rho')
|
|
|
720190 |
|
|
|
720190 |
if sbox.repo_url.startswith('http'):
|
|
|
720190 |
@@ -626,10 +628,11 @@ def authz_log_and_tracing_test(sbox):
|
|
|
720190 |
svntest.actions.run_and_verify_svn(None, None, expected_err,
|
|
|
720190 |
'diff', '-r', 'HEAD', G_url+'/rho')
|
|
|
720190 |
|
|
|
720190 |
- svntest.actions.run_and_verify_svn(None, None, expected_err,
|
|
|
720190 |
+ # diff treats the unreadable path as indicating an add so no error
|
|
|
720190 |
+ svntest.actions.run_and_verify_svn(None, None, [],
|
|
|
720190 |
'diff', '-r', '2', D_url+'/rho')
|
|
|
720190 |
|
|
|
720190 |
- svntest.actions.run_and_verify_svn(None, None, expected_err,
|
|
|
720190 |
+ svntest.actions.run_and_verify_svn(None, None, [],
|
|
|
720190 |
'diff', '-r', '2:4', D_url+'/rho')
|
|
|
720190 |
|
|
|
720190 |
# test whether read access is correctly granted and denied
|
|
|
720190 |
diff -uap subversion-1.7.14/subversion/tests/libsvn_repos/repos-test.c.cve3187 subversion-1.7.14/subversion/tests/libsvn_repos/repos-test.c
|
|
|
720190 |
--- subversion-1.7.14/subversion/tests/libsvn_repos/repos-test.c.cve3187
|
|
|
720190 |
+++ subversion-1.7.14/subversion/tests/libsvn_repos/repos-test.c
|
|
|
720190 |
@@ -2526,6 +2526,246 @@ issue_4060(const svn_test_opts_t *opts,
|
|
|
720190 |
return SVN_NO_ERROR;
|
|
|
720190 |
}
|
|
|
720190 |
|
|
|
720190 |
+static svn_error_t *
|
|
|
720190 |
+mkdir_delete_copy(svn_repos_t *repos,
|
|
|
720190 |
+ const char *src,
|
|
|
720190 |
+ const char *dst,
|
|
|
720190 |
+ apr_pool_t *pool)
|
|
|
720190 |
+{
|
|
|
720190 |
+ svn_fs_t *fs = svn_repos_fs(repos);
|
|
|
720190 |
+ svn_revnum_t youngest_rev;
|
|
|
720190 |
+ svn_fs_txn_t *txn;
|
|
|
720190 |
+ svn_fs_root_t *txn_root, *rev_root;
|
|
|
720190 |
+
|
|
|
720190 |
+ SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_make_dir(txn_root, "A/T", pool));
|
|
|
720190 |
+ SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_delete(txn_root, "A/T", pool));
|
|
|
720190 |
+ SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_revision_root(&rev_root, fs, youngest_rev - 1, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_copy(rev_root, src, txn_root, dst, pool));
|
|
|
720190 |
+ SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ return SVN_NO_ERROR;
|
|
|
720190 |
+}
|
|
|
720190 |
+
|
|
|
720190 |
+struct authz_read_baton_t {
|
|
|
720190 |
+ apr_hash_t *paths;
|
|
|
720190 |
+ apr_pool_t *pool;
|
|
|
720190 |
+ const char *deny;
|
|
|
720190 |
+};
|
|
|
720190 |
+
|
|
|
720190 |
+static svn_error_t *
|
|
|
720190 |
+authz_read_func(svn_boolean_t *allowed,
|
|
|
720190 |
+ svn_fs_root_t *root,
|
|
|
720190 |
+ const char *path,
|
|
|
720190 |
+ void *baton,
|
|
|
720190 |
+ apr_pool_t *pool)
|
|
|
720190 |
+{
|
|
|
720190 |
+ struct authz_read_baton_t *b = baton;
|
|
|
720190 |
+
|
|
|
720190 |
+ if (b->deny && !strcmp(b->deny, path))
|
|
|
720190 |
+ *allowed = FALSE;
|
|
|
720190 |
+ else
|
|
|
720190 |
+ *allowed = TRUE;
|
|
|
720190 |
+
|
|
|
720190 |
+ apr_hash_set(b->paths, apr_pstrdup(b->pool, path), APR_HASH_KEY_STRING,
|
|
|
720190 |
+ (void*)1);
|
|
|
720190 |
+
|
|
|
720190 |
+ return SVN_NO_ERROR;
|
|
|
720190 |
+}
|
|
|
720190 |
+
|
|
|
720190 |
+static svn_error_t *
|
|
|
720190 |
+verify_locations(apr_hash_t *actual,
|
|
|
720190 |
+ apr_hash_t *expected,
|
|
|
720190 |
+ apr_hash_t *checked,
|
|
|
720190 |
+ apr_pool_t *pool)
|
|
|
720190 |
+{
|
|
|
720190 |
+ apr_hash_index_t *hi;
|
|
|
720190 |
+
|
|
|
720190 |
+ for (hi = apr_hash_first(pool, expected); hi; hi = apr_hash_next(hi))
|
|
|
720190 |
+ {
|
|
|
720190 |
+ const svn_revnum_t *rev = svn__apr_hash_index_key(hi);
|
|
|
720190 |
+ const char *path = apr_hash_get(actual, rev, sizeof(svn_revnum_t));
|
|
|
720190 |
+
|
|
|
720190 |
+ if (!path)
|
|
|
720190 |
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
|
|
|
720190 |
+ "expected %s for %d found (null)",
|
|
|
720190 |
+ (char*)svn__apr_hash_index_val(hi),
|
|
|
720190 |
+ (int)*rev);
|
|
|
720190 |
+ else if (strcmp(path, svn__apr_hash_index_val(hi)))
|
|
|
720190 |
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
|
|
|
720190 |
+ "expected %s for %d found %s",
|
|
|
720190 |
+ (char*)svn__apr_hash_index_val(hi),
|
|
|
720190 |
+ (int)*rev, path);
|
|
|
720190 |
+
|
|
|
720190 |
+ }
|
|
|
720190 |
+
|
|
|
720190 |
+ for (hi = apr_hash_first(pool, actual); hi; hi = apr_hash_next(hi))
|
|
|
720190 |
+ {
|
|
|
720190 |
+ const svn_revnum_t *rev = svn__apr_hash_index_key(hi);
|
|
|
720190 |
+ const char *path = apr_hash_get(expected, rev, sizeof(svn_revnum_t));
|
|
|
720190 |
+
|
|
|
720190 |
+ if (!path)
|
|
|
720190 |
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
|
|
|
720190 |
+ "found %s for %d expected (null)",
|
|
|
720190 |
+ (char*)svn__apr_hash_index_val(hi),
|
|
|
720190 |
+ (int)*rev);
|
|
|
720190 |
+ else if (strcmp(path, svn__apr_hash_index_val(hi)))
|
|
|
720190 |
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
|
|
|
720190 |
+ "found %s for %d expected %s",
|
|
|
720190 |
+ (char*)svn__apr_hash_index_val(hi),
|
|
|
720190 |
+ (int)*rev, path);
|
|
|
720190 |
+
|
|
|
720190 |
+ if (!apr_hash_get(checked, path, APR_HASH_KEY_STRING))
|
|
|
720190 |
+ return svn_error_createf(SVN_ERR_TEST_FAILED, NULL,
|
|
|
720190 |
+ "did not check %s", path);
|
|
|
720190 |
+ }
|
|
|
720190 |
+
|
|
|
720190 |
+ return SVN_NO_ERROR;
|
|
|
720190 |
+}
|
|
|
720190 |
+
|
|
|
720190 |
+static void
|
|
|
720190 |
+set_expected(apr_hash_t *expected,
|
|
|
720190 |
+ svn_revnum_t rev,
|
|
|
720190 |
+ const char *path,
|
|
|
720190 |
+ apr_pool_t *pool)
|
|
|
720190 |
+{
|
|
|
720190 |
+ svn_revnum_t *rp = apr_palloc(pool, sizeof(svn_revnum_t));
|
|
|
720190 |
+ *rp = rev;
|
|
|
720190 |
+ apr_hash_set(expected, rp, sizeof(svn_revnum_t), path);
|
|
|
720190 |
+}
|
|
|
720190 |
+
|
|
|
720190 |
+static svn_error_t *
|
|
|
720190 |
+trace_node_locations_authz(const svn_test_opts_t *opts,
|
|
|
720190 |
+ apr_pool_t *pool)
|
|
|
720190 |
+{
|
|
|
720190 |
+ svn_repos_t *repos;
|
|
|
720190 |
+ svn_fs_t *fs;
|
|
|
720190 |
+ svn_revnum_t youngest_rev = 0;
|
|
|
720190 |
+ svn_fs_txn_t *txn;
|
|
|
720190 |
+ svn_fs_root_t *txn_root;
|
|
|
720190 |
+ struct authz_read_baton_t arb;
|
|
|
720190 |
+ apr_array_header_t *revs = apr_array_make(pool, 10, sizeof(svn_revnum_t));
|
|
|
720190 |
+ apr_hash_t *locations;
|
|
|
720190 |
+ apr_hash_t *expected = apr_hash_make(pool);
|
|
|
720190 |
+ int i;
|
|
|
720190 |
+
|
|
|
720190 |
+ /* Create test repository. */
|
|
|
720190 |
+ SVN_ERR(svn_test__create_repos(&repos, "test-repo-trace-node-locations-authz",
|
|
|
720190 |
+ opts, pool));
|
|
|
720190 |
+ fs = svn_repos_fs(repos);
|
|
|
720190 |
+
|
|
|
720190 |
+ /* r1 create A */
|
|
|
720190 |
+ SVN_ERR(svn_fs_begin_txn(&txn, fs, youngest_rev, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_txn_root(&txn_root, txn, pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_make_dir(txn_root, "A", pool));
|
|
|
720190 |
+ SVN_ERR(svn_fs_make_file(txn_root, "A/f", pool));
|
|
|
720190 |
+ SVN_ERR(svn_test__set_file_contents(txn_root, "A/f", "foobar", pool));
|
|
|
720190 |
+ SVN_ERR(svn_repos_fs_commit_txn(NULL, repos, &youngest_rev, txn, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ /* r4 copy A to B */
|
|
|
720190 |
+ SVN_ERR(mkdir_delete_copy(repos, "A", "B", pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ /* r7 copy B to C */
|
|
|
720190 |
+ SVN_ERR(mkdir_delete_copy(repos, "B", "C", pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ /* r10 copy C to D */
|
|
|
720190 |
+ SVN_ERR(mkdir_delete_copy(repos, "C", "D", pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ SVN_ERR(svn_fs_youngest_rev(&youngest_rev, fs, pool));
|
|
|
720190 |
+ SVN_ERR_ASSERT(youngest_rev == 10);
|
|
|
720190 |
+
|
|
|
720190 |
+ arb.paths = apr_hash_make(pool);
|
|
|
720190 |
+ arb.pool = pool;
|
|
|
720190 |
+ arb.deny = NULL;
|
|
|
720190 |
+
|
|
|
720190 |
+ apr_array_clear(revs);
|
|
|
720190 |
+ for (i = 0; i <= youngest_rev; ++i)
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = i;
|
|
|
720190 |
+ set_expected(expected, 10, "/D/f", pool);
|
|
|
720190 |
+ set_expected(expected, 8, "/C/f", pool);
|
|
|
720190 |
+ set_expected(expected, 7, "/C/f", pool);
|
|
|
720190 |
+ set_expected(expected, 5, "/B/f", pool);
|
|
|
720190 |
+ set_expected(expected, 4, "/B/f", pool);
|
|
|
720190 |
+ set_expected(expected, 2, "/A/f", pool);
|
|
|
720190 |
+ set_expected(expected, 1, "/A/f", pool);
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ apr_array_clear(revs);
|
|
|
720190 |
+ for (i = 1; i <= youngest_rev; ++i)
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = i;
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ apr_array_clear(revs);
|
|
|
720190 |
+ for (i = 2; i <= youngest_rev; ++i)
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = i;
|
|
|
720190 |
+ set_expected(expected, 1, NULL, pool);
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ apr_array_clear(revs);
|
|
|
720190 |
+ for (i = 3; i <= youngest_rev; ++i)
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = i;
|
|
|
720190 |
+ set_expected(expected, 2, NULL, pool);
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ apr_array_clear(revs);
|
|
|
720190 |
+ for (i = 6; i <= youngest_rev; ++i)
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = i;
|
|
|
720190 |
+ set_expected(expected, 5, NULL, pool);
|
|
|
720190 |
+ set_expected(expected, 4, NULL, pool);
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ arb.deny = "/B/f";
|
|
|
720190 |
+ apr_array_clear(revs);
|
|
|
720190 |
+ for (i = 0; i <= youngest_rev; ++i)
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = i;
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ apr_array_clear(revs);
|
|
|
720190 |
+ for (i = 6; i <= youngest_rev; ++i)
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = i;
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ APR_ARRAY_PUSH(revs, svn_revnum_t) = 0;
|
|
|
720190 |
+ apr_hash_clear(arb.paths);
|
|
|
720190 |
+ SVN_ERR(svn_repos_trace_node_locations(fs, &locations, "D/f", 10, revs,
|
|
|
720190 |
+ authz_read_func, &arb, pool));
|
|
|
720190 |
+ SVN_ERR(verify_locations(locations, expected, arb.paths, pool));
|
|
|
720190 |
+
|
|
|
720190 |
+ return SVN_NO_ERROR;
|
|
|
720190 |
+}
|
|
|
720190 |
+
|
|
|
720190 |
|
|
|
720190 |
/* The test table. */
|
|
|
720190 |
|
|
|
720190 |
@@ -2562,5 +2802,7 @@ struct svn_test_descriptor_t test_funcs[
|
|
|
720190 |
"test svn_repos_get_file_revsN"),
|
|
|
720190 |
SVN_TEST_OPTS_PASS(issue_4060,
|
|
|
720190 |
"test issue 4060"),
|
|
|
720190 |
+ SVN_TEST_OPTS_PASS(trace_node_locations_authz,
|
|
|
720190 |
+ "authz for svn_repos_trace_node_locations"),
|
|
|
720190 |
SVN_TEST_NULL
|
|
|
720190 |
};
|