subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1717580 [1/2] - in /subversion/branches/ra-git: ./ build/ build/generator/ subversion/ subversion/include/ subversion/libsvn_fs/ subversion/libsvn_fs_fs/ subversion/libsvn_fs_x/ subversion/libsvn_ra/ subversion/libsvn_ra_local/ subversion/...
Date Wed, 02 Dec 2015 07:55:55 GMT
Author: rhuijben
Date: Wed Dec  2 07:55:55 2015
New Revision: 1717580

URL: http://svn.apache.org/viewvc?rev=1717580&view=rev
Log:
On the ra-git branch: Catch up with trunk at r1717578

Modified:
    subversion/branches/ra-git/   (props changed)
    subversion/branches/ra-git/build/generator/gen_win_dependencies.py
    subversion/branches/ra-git/build/run_tests.py
    subversion/branches/ra-git/configure.ac
    subversion/branches/ra-git/subversion/include/svn_error_codes.h
    subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h
    subversion/branches/ra-git/subversion/libsvn_fs_fs/cached_data.c
    subversion/branches/ra-git/subversion/libsvn_fs_fs/index.c
    subversion/branches/ra-git/subversion/libsvn_fs_fs/pack.c
    subversion/branches/ra-git/subversion/libsvn_fs_fs/revprops.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/   (props changed)
    subversion/branches/ra-git/subversion/libsvn_fs_x/cached_data.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/fs.h
    subversion/branches/ra-git/subversion/libsvn_fs_x/fs_x.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/index.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.h
    subversion/branches/ra-git/subversion/libsvn_fs_x/pack.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.h
    subversion/branches/ra-git/subversion/libsvn_fs_x/transaction.c
    subversion/branches/ra-git/subversion/libsvn_fs_x/tree.c
    subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.c
    subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.h
    subversion/branches/ra-git/subversion/libsvn_ra_local/ra_plugin.c
    subversion/branches/ra-git/subversion/libsvn_ra_serf/serf.c
    subversion/branches/ra-git/subversion/libsvn_ra_svn/client.c
    subversion/branches/ra-git/subversion/libsvn_ra_svn/marshal.c
    subversion/branches/ra-git/subversion/libsvn_subr/base64.c
    subversion/branches/ra-git/subversion/libsvn_subr/cache-membuffer.c
    subversion/branches/ra-git/subversion/libsvn_subr/stream.c
    subversion/branches/ra-git/subversion/libsvn_subr/string.c
    subversion/branches/ra-git/subversion/svn_private_config.hw
    subversion/branches/ra-git/subversion/tests/cmdline/svnmover_tests.py

Propchange: subversion/branches/ra-git/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  2 07:55:55 2015
@@ -95,4 +95,4 @@
 /subversion/branches/verify-at-commit:1462039-1462408
 /subversion/branches/verify-keep-going:1439280-1546110
 /subversion/branches/wc-collate-path:1402685-1480384
-/subversion/trunk:1583624-1717222
+/subversion/trunk:1583624-1717578

Modified: subversion/branches/ra-git/build/generator/gen_win_dependencies.py
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/build/generator/gen_win_dependencies.py?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/build/generator/gen_win_dependencies.py (original)
+++ subversion/branches/ra-git/build/generator/gen_win_dependencies.py Wed Dec  2 07:55:55 2015
@@ -1243,7 +1243,7 @@ class GenDependenciesBase(gen_base.Gener
     else:
       lib_name = 'serf.lib'
 
-    defines = ['SVN_HAVE_SERF', 'SVN_LIBSVN_CLIENT_LINKS_RA_SERF']
+    defines = ['SVN_HAVE_SERF', 'SVN_LIBSVN_RA_LINKS_RA_SERF']
 
     self._libraries['serf'] = SVNCommonLibrary('serf', inc_dir, lib_dir,
                                                 lib_name, serf_version,

Modified: subversion/branches/ra-git/build/run_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/build/run_tests.py?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/build/run_tests.py (original)
+++ subversion/branches/ra-git/build/run_tests.py Wed Dec  2 07:55:55 2015
@@ -431,7 +431,7 @@ class TestHarness:
     job_queue = queue.Queue()
     total_count = 0
     scrambled = list(jobs)
-    scrambled.sort(key=lambda x: x.number)
+    scrambled.sort(key=lambda x: str(x.number))
     for job in scrambled:
       total_count += job.test_count()
       job_queue.put(job)
@@ -461,6 +461,7 @@ class TestHarness:
 
     # Actually run the tests in concurrent sub-processes
     print('Tests to execute: %d' % total_count)
+    sys.stdout.flush()
 
     threads = [ TestHarness.TestSpawningThread(job_queue, self)
                 for i in range(thread_count) ]

Modified: subversion/branches/ra-git/configure.ac
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/configure.ac?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/configure.ac (original)
+++ subversion/branches/ra-git/configure.ac Wed Dec  2 07:55:55 2015
@@ -1374,19 +1374,19 @@ AS_HELP_STRING([--enable-runtime-module-
 ])
 
 if test "$svn_enable_shared" = "no" || test "$use_dso" != "yes"; then
-  AC_DEFINE(SVN_LIBSVN_CLIENT_LINKS_RA_LOCAL, 1,
+  AC_DEFINE(SVN_LIBSVN_RA_LINKS_RA_LOCAL, 1,
       [Defined if libsvn_client should link against libsvn_ra_local])
   svn_ra_lib_deps="\$(RA_LOCAL_DEPS)"
   svn_ra_lib_install_deps="install-ramod-lib"
   svn_ra_lib_link="\$(RA_LOCAL_LINK)"
 
-  AC_DEFINE(SVN_LIBSVN_CLIENT_LINKS_RA_SVN, 1,
+  AC_DEFINE(SVN_LIBSVN_RA_LINKS_RA_SVN, 1,
       [Defined if libsvn_client should link against libsvn_ra_svn])
   svn_ra_lib_deps="$svn_ra_lib_deps \$(RA_SVN_DEPS)"
   svn_ra_lib_link="$svn_ra_lib_link \$(RA_SVN_LINK)"
 
   if test "$svn_lib_serf" = "yes"; then
-    AC_DEFINE(SVN_LIBSVN_CLIENT_LINKS_RA_SERF, 1,
+    AC_DEFINE(SVN_LIBSVN_RA_LINKS_RA_SERF, 1,
           [Defined if libsvn_client should link against libsvn_ra_serf])
     svn_ra_lib_deps="$svn_ra_lib_deps \$(RA_SERF_DEPS)"
     svn_ra_lib_install_deps="$svn_ra_lib_install_deps install-serf-lib"

Modified: subversion/branches/ra-git/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/include/svn_error_codes.h?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/include/svn_error_codes.h (original)
+++ subversion/branches/ra-git/subversion/include/svn_error_codes.h Wed Dec  2 07:55:55 2015
@@ -876,6 +876,11 @@ SVN_ERROR_START
              SVN_ERR_FS_CATEGORY_START + 64,
              "Revprop manifest corrupt.")
 
+  /** @since New in 1.10. */
+  SVN_ERRDEF(SVN_ERR_FS_CORRUPT_PROPLIST,
+             SVN_ERR_FS_CATEGORY_START + 65,
+             "Property list is corrupt.")
+
   /* repos errors */
 
   SVN_ERRDEF(SVN_ERR_REPOS_LOCKED,

Modified: subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs/fs-loader.h Wed Dec  2 07:55:55 2015
@@ -525,7 +525,7 @@ struct svn_fs_root_t
   svn_revnum_t rev;
 
   /* FSAP-specific vtable and private data */
-  root_vtable_t *vtable;
+  const root_vtable_t *vtable;
   void *fsap_data;
 };
 
@@ -533,7 +533,7 @@ struct svn_fs_root_t
 struct svn_fs_history_t
 {
   /* FSAP-specific vtable and private data */
-  history_vtable_t *vtable;
+  const history_vtable_t *vtable;
   void *fsap_data;
 };
 
@@ -541,7 +541,7 @@ struct svn_fs_history_t
 struct svn_fs_id_t
 {
   /* FSAP-specific vtable and private data */
-  id_vtable_t *vtable;
+  const id_vtable_t *vtable;
   void *fsap_data;
 };
 

Modified: subversion/branches/ra-git/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_fs/cached_data.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_fs/cached_data.c Wed Dec  2 07:55:55 2015
@@ -1801,10 +1801,10 @@ get_contents_from_windows(struct rep_rea
              This is where we need the pseudo rep_state created
              by build_rep_list(). */
           apr_size_t offset = (apr_size_t)rs->current;
-          if (copy_len + offset > rb->base_window->len)
-            copy_len = offset < rb->base_window->len
-                     ? rb->base_window->len - offset
-                     : 0ul;
+          if (offset >= rb->base_window->len)
+            copy_len = 0ul;
+          else if (copy_len > rb->base_window->len - offset)
+            copy_len = rb->base_window->len - offset;
 
           memcpy (cur, rb->base_window->data + offset, copy_len);
         }
@@ -3540,7 +3540,7 @@ block_read(void **result,
               /* if we crossed a block boundary, read the remainder of
                * the last block as well */
               offset = entry->offset + entry->size;
-              if (offset > block_start + ffd->block_size)
+              if (offset - block_start > ffd->block_size)
                 ++run_count;
             }
         }

Modified: subversion/branches/ra-git/subversion/libsvn_fs_fs/index.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_fs/index.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_fs/index.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_fs/index.c Wed Dec  2 07:55:55 2015
@@ -1736,7 +1736,7 @@ svn_fs_fs__l2p_get_max_ids(apr_array_hea
       apr_uint64_t item_count;
       apr_size_t first_page_index, last_page_index;
 
-      if (revision >= header->first_revision + header->revision_count)
+      if (revision - header->first_revision >= header->revision_count)
         {
           /* need to read the next index. Clear up memory used for the
            * previous one.  Note that intermittent pack runs do not change
@@ -2422,6 +2422,13 @@ read_entry(svn_fs_fs__packed_number_stre
       return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
                  _("Empty regions must have item number 0 and checksum 0"));
 
+  /* Corrupted SIZE values might cause arithmetic overflow.
+   * The same can happen if you copy a repository from a system with 63 bit
+   * file lengths to one with 31 bit file lengths. */
+  if ((apr_uint64_t)entry.offset + (apr_uint64_t)entry.size > off_t_max)
+    return svn_error_create(SVN_ERR_FS_INDEX_OVERFLOW , NULL,
+                            _("P2L index entry size overflow."));
+
   APR_ARRAY_PUSH(result, svn_fs_fs__p2l_entry_t) = entry;
   *item_offset += entry.size;
 

Modified: subversion/branches/ra-git/subversion/libsvn_fs_fs/pack.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_fs/pack.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_fs/pack.c Wed Dec  2 07:55:55 2015
@@ -1560,7 +1560,8 @@ pack_log_addressed(svn_fs_t *fs,
 
   /* pack revisions in ranges that don't exceed MAX_MEM */
   for (i = 0; i < max_ids->nelts; ++i)
-    if (APR_ARRAY_IDX(max_ids, i, apr_uint64_t) + item_count <= max_items)
+    if (   APR_ARRAY_IDX(max_ids, i, apr_uint64_t)
+        <= (apr_uint64_t)max_items - item_count)
       {
         context.end_rev++;
       }

Modified: subversion/branches/ra-git/subversion/libsvn_fs_fs/revprops.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_fs/revprops.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_fs/revprops.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_fs/revprops.c Wed Dec  2 07:55:55 2015
@@ -524,7 +524,7 @@ parse_packed_revprops(svn_fs_t *fs,
       /* read & check the serialized size */
       SVN_ERR(svn_fs_fs__read_number_from_stream(&size, NULL, stream,
                                                  iterpool));
-      if (size + offset > (apr_int64_t)revprops->packed_revprops->len)
+      if (size > (apr_int64_t)revprops->packed_revprops->len - offset)
         return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                         _("Packed revprop size exceeds pack file size"));
 
@@ -1377,10 +1377,13 @@ svn_fs_fs__pack_revprops_shard(const cha
                              iterpool);
       SVN_ERR(svn_io_stat(&finfo, path, APR_FINFO_SIZE, iterpool));
 
-      /* if we already have started a pack file and this revprop cannot be
-       * appended to it, write the previous pack file. */
-      if (sizes->nelts != 0 &&
-          total_size + SVN_INT64_BUFFER_SIZE + finfo.size > max_size)
+      /* If we already have started a pack file and this revprop cannot be
+       * appended to it, write the previous pack file.  Note this overflow
+       * check works because we enforced MAX_SIZE <= SVN_MAX_OBJECT_SIZE. */
+      if (sizes->nelts != 0
+          && (   finfo.size > max_size
+              || total_size > max_size
+              || SVN_INT64_BUFFER_SIZE + finfo.size > max_size - total_size))
         {
           SVN_ERR(svn_fs_fs__copy_revprops(pack_file_dir, pack_filename,
                                            shard_path, start_rev, rev-1,

Propchange: subversion/branches/ra-git/subversion/libsvn_fs_x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  2 07:55:55 2015
@@ -94,5 +94,5 @@
 /subversion/branches/verify-at-commit/subversion/libsvn_fs_x:1462039-1462408
 /subversion/branches/verify-keep-going/subversion/libsvn_fs_x:1439280-1492639,1546002-1546110
 /subversion/branches/wc-collate-path/subversion/libsvn_fs_x:1402685-1480384
-/subversion/trunk/subversion/libsvn_fs_fs:1415133-1596500,1596567,1597414,1597989,1598273,1599140,1600872,1601633,1603485-1603487,1603499,1603605,1604128,1604188,1604413-1604414,1604416-1604417,1604421,1604442,1604700,1604717,1604720,1604726,1604755,1604794,1604802,1604824,1604836,1604844,1604902-1604903,1604911,1604925,1604933,1604947,1605059-1605060,1605064-1605065,1605068,1605071-1605073,1605075,1605123,1605188-1605189,1605191,1605197,1605444,1605633,1606132,1606142,1606144,1606514,1606526,1606528,1606551,1606554,1606564,1606598-1606599,1606656,1606658,1606662,1606744,1606840,1607085,1607572,1612407,1612810,1613339,1613872,1614611,1615348,1615351-1615352,1615356,1616338-1616339,1616613,1617586,1617688,1618138,1618151,1618153,1618226,1618641,1618653,1618662,1619068,1619358,1619413,1619769,1619774,1620602,1620909,1620912,1620928,1620930,1621275,1621635,1622931,1622937,1622942,1622946,1622959-1622960,1622963,1622987,1623007,1623368,1623373,1623377,1623379,1623381,1623398,1623402,162
 4011,1624265,1624512,1626246,1626871,1626873,1626886,1627497-1627498,1627502,1627947-1627949,1627966,1628083,1628093,1628158-1628159,1628161,1628392-1628393,1628415,1628427,1628676,1628738,1628762,1628764,1629854-1629855,1629857,1629865,1629873,1629875,1629879,1630067,1630070,1631049-1631051,1631075,1631115,1631171,1631180,1631185-1631186,1631196-1631197,1631239-1631240,1631548,1631550,1631563,1631567,1631588,1631598,1632646,1632776,1632849,1632851-1632853,1632856-1632857,1632868,1632908,1632926,1633232,1633617-1633618,1634872,1634875,1634879-1634880,1634920,1636478,1636483,1636629,1636644,1637184,1637186,1637330,1637358,1637363,1637393,1639319,1639322,1639335,1639348,1639352,1639355,1639358,1639414,1639419,1639426,1639430,1639436,1639440,1639549,1640061-1640062,1640197,1640915,1640966,1641013,1643139,1643233,1645567,1646021,1646712,1646716,1647537,1647540-1647541,1647820,1647905,1648230,1648238,1648241-1648243,1648253,1648272,1648532,1648537-1648539,1648542,1648591,1648612,1649590,
 1651567,1652068,1652076,1652441,1652451,1653608,1654932,1654934,1654937,1655635,1655649,1655651,1655664,1656176,1657525,1657972,1657978,1658482,1659212,1659217,1659314,1659509,1662668,1665318,1665854,1665894,1667090,1667101,1667538,1669743,1669746,1669749,1669945,1670139,1670953,1673170,1673197,1673202,1673204,1673445,1673454,1673685,1673689,1673875,1674165,1674341,1674400,1674404,1674631,1674669,1674673,1675396,1676667,1677431,1678149,1678151,1678718,1678725,1679169,1679907,1679920-1679924,1679926,1680347,1680460,1680464,1680476,1680819,1681949,1681966,1681974,1681994,1682008,1682076,1682086,1682093,1682259,1682265,1682739,1682864,1683311,1683330,1683378,1683544,1683553,1684047,1686232,1686542,1686546,1686554,1686557,1687061,1687064,1687070-1687071,1687074,1687078-1687079,1688270,1688425,1692650,1693886,1694489,1694848,1696171,1696185,1696627-1696628,1696630,1696758,1697372,1697381,1697387,1697393,1697403,1697405,1701017,1701053,1702600,1702922,1703069,1703142,1703237,1703240,17052
 66,1705638,1705643,1705646,1705724,1705730,1705739,1706612,1706615,1706617,1706619,1706675-1706676,1706679,1706979-1706980,1707308,1707971-1707973,1707986,1707988-1707989,1708004
-/subversion/trunk/subversion/libsvn_fs_x:1414756-1509914,1583624-1717222
+/subversion/trunk/subversion/libsvn_fs_fs:1415133-1596500,1596567,1597414,1597989,1598273,1599140,1600872,1601633,1603485-1603487,1603499,1603605,1604128,1604188,1604413-1604414,1604416-1604417,1604421,1604442,1604700,1604717,1604720,1604726,1604755,1604794,1604802,1604824,1604836,1604844,1604902-1604903,1604911,1604925,1604933,1604947,1605059-1605060,1605064-1605065,1605068,1605071-1605073,1605075,1605123,1605188-1605189,1605191,1605197,1605444,1605633,1606132,1606142,1606144,1606514,1606526,1606528,1606551,1606554,1606564,1606598-1606599,1606656,1606658,1606662,1606744,1606840,1607085,1607572,1612407,1612810,1613339,1613872,1614611,1615348,1615351-1615352,1615356,1616338-1616339,1616613,1617586,1617688,1618138,1618151,1618153,1618226,1618641,1618653,1618662,1619068,1619358,1619413,1619769,1619774,1620602,1620909,1620912,1620928,1620930,1621275,1621635,1622931,1622937,1622942,1622946,1622959-1622960,1622963,1622987,1623007,1623368,1623373,1623377,1623379,1623381,1623398,1623402,162
 4011,1624265,1624512,1626246,1626871,1626873,1626886,1627497-1627498,1627502,1627947-1627949,1627966,1628083,1628093,1628158-1628159,1628161,1628392-1628393,1628415,1628427,1628676,1628738,1628762,1628764,1629854-1629855,1629857,1629865,1629873,1629875,1629879,1630067,1630070,1631049-1631051,1631075,1631115,1631171,1631180,1631185-1631186,1631196-1631197,1631239-1631240,1631548,1631550,1631563,1631567,1631588,1631598,1632646,1632776,1632849,1632851-1632853,1632856-1632857,1632868,1632908,1632926,1633232,1633617-1633618,1634872,1634875,1634879-1634880,1634920,1636478,1636483,1636629,1636644,1637184,1637186,1637330,1637358,1637363,1637393,1639319,1639322,1639335,1639348,1639352,1639355,1639358,1639414,1639419,1639426,1639430,1639436,1639440,1639549,1640061-1640062,1640197,1640915,1640966,1641013,1643139,1643233,1645567,1646021,1646712,1646716,1647537,1647540-1647541,1647820,1647905,1648230,1648238,1648241-1648243,1648253,1648272,1648532,1648537-1648539,1648542,1648591,1648612,1649590,
 1651567,1652068,1652076,1652441,1652451,1653608,1654932,1654934,1654937,1655635,1655649,1655651,1655664,1656176,1657525,1657972,1657978,1658482,1659212,1659217,1659314,1659509,1662668,1665318,1665854,1665894,1667090,1667101,1667538,1669743,1669746,1669749,1669945,1670139,1670953,1673170,1673197,1673202,1673204,1673445,1673454,1673685,1673689,1673875,1674165,1674341,1674400,1674404,1674631,1674669,1674673,1675396,1676667,1677431,1678149,1678151,1678718,1678725,1679169,1679907,1679920-1679924,1679926,1680347,1680460,1680464,1680476,1680819,1681949,1681966,1681974,1681994,1682008,1682076,1682086,1682093,1682259,1682265,1682739,1682864,1683311,1683330,1683378,1683544,1683553,1684047,1686232,1686542,1686546,1686554,1686557,1687061,1687064,1687070-1687071,1687074,1687078-1687079,1688270,1688425,1692650,1693886,1694489,1694848,1696171,1696185,1696627-1696628,1696630,1696758,1697372,1697381,1697387,1697393,1697403,1697405,1701017,1701053,1702600,1702922,1703069,1703142,1703237,1703240,17052
 66,1705638,1705643,1705646,1705724,1705730,1705739,1706612,1706615,1706617,1706619,1706675-1706676,1706679,1706979-1706980,1707308,1707971-1707973,1707986,1707988-1707989,1708004,1709799,1710017,1710359,1711582,1711672,1712927,1715793,1715947,1716047,1716067,1716784,1716973-1716974,1717332,1717334
+/subversion/trunk/subversion/libsvn_fs_x:1414756-1509914,1583624-1717578

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/cached_data.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/cached_data.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/cached_data.c Wed Dec  2 07:55:55 2015
@@ -30,6 +30,7 @@
 
 #include "private/svn_io_private.h"
 #include "private/svn_sorts_private.h"
+#include "private/svn_string_private.h"
 #include "private/svn_subr_private.h"
 #include "private/svn_temp_serializer.h"
 
@@ -288,14 +289,13 @@ get_node_revision_body(svn_fs_x__noderev
                                                          scratch_pool),
                              APR_READ | APR_BUFFERED, APR_OS_DEFAULT,
                              scratch_pool);
-      if (err)
+      if (err && APR_STATUS_IS_ENOENT(err->apr_err))
+        {
+          svn_error_clear(err);
+          return svn_error_trace(err_dangling_id(fs, id));
+        }
+      else if (err)
         {
-          if (APR_STATUS_IS_ENOENT(err->apr_err))
-            {
-              svn_error_clear(err);
-              return svn_error_trace(err_dangling_id(fs, id));
-            }
-
           return svn_error_trace(err);
         }
 
@@ -1748,10 +1748,10 @@ get_contents_from_windows(rep_read_baton
              This is where we need the pseudo rep_state created
              by build_rep_list(). */
           apr_size_t offset = (apr_size_t)rs->current;
-          if (copy_len + offset > rb->base_window->len)
-            copy_len = offset < rb->base_window->len
-                     ? rb->base_window->len - offset
-                     : 0ul;
+          if (offset >= rb->base_window->len)
+            copy_len = 0ul;
+          else if (copy_len > rb->base_window->len - offset)
+            copy_len = rb->base_window->len - offset;
 
           memcpy (cur, rb->base_window->data + offset, copy_len);
         }
@@ -2728,89 +2728,67 @@ svn_fs_x__rep_contents_dir_entry(svn_fs_
 }
 
 svn_error_t *
-svn_fs_x__get_proplist(apr_hash_t **proplist_p,
+svn_fs_x__get_proplist(apr_hash_t **proplist,
                        svn_fs_t *fs,
                        svn_fs_x__noderev_t *noderev,
                        apr_pool_t *result_pool,
                        apr_pool_t *scratch_pool)
 {
-  apr_hash_t *proplist;
   svn_stream_t *stream;
   const svn_fs_x__id_t *noderev_id = &noderev->noderev_id;
-  svn_error_t *err;
 
   if (noderev->prop_rep
       && !svn_fs_x__is_revision(noderev->prop_rep->id.change_set))
     {
+      svn_stringbuf_t *content;
+      svn_string_t *as_string;
       const char *filename = svn_fs_x__path_txn_node_props(fs, noderev_id,
                                                            scratch_pool,
                                                            scratch_pool);
-      proplist = apr_hash_make(result_pool);
+      SVN_ERR(svn_stringbuf_from_file2(&content, filename, result_pool));
 
-      SVN_ERR(svn_stream_open_readonly(&stream, filename, scratch_pool,
-                                       scratch_pool));
-      err = svn_hash_read2(proplist, stream, SVN_HASH_TERMINATOR,
-                          result_pool);
-      if (err)
-        {
-          svn_string_t *id_str = svn_fs_x__id_unparse(&noderev->noderev_id,
-                                                      scratch_pool);
-
-          err = svn_error_compose_create(err, svn_stream_close(stream));
-          return svn_error_quick_wrapf(err,
-                   _("malformed property list for node-revision '%s' in '%s'"),
-                   id_str->data, filename);
-        }
-
-      SVN_ERR(svn_stream_close(stream));
+      as_string = svn_stringbuf__morph_into_string(content);
+      SVN_ERR_W(svn_fs_x__parse_properties(proplist, as_string, result_pool),
+                apr_psprintf(scratch_pool,
+                    "malformed property list for node-revision '%s' in '%s'",
+                    svn_fs_x__id_unparse(&noderev->noderev_id,
+                                         scratch_pool)->data,
+                    filename));
     }
   else if (noderev->prop_rep)
     {
       svn_fs_x__data_t *ffd = fs->fsap_data;
       svn_fs_x__representation_t *rep = noderev->prop_rep;
       svn_fs_x__pair_cache_key_t key = { 0 };
+      svn_string_t *content;
+      svn_boolean_t is_cached;
 
       key.revision = svn_fs_x__get_revnum(rep->id.change_set);
       key.second = rep->id.number;
-      if (SVN_IS_VALID_REVNUM(key.revision))
-        {
-          svn_boolean_t is_cached;
-          SVN_ERR(svn_cache__get((void **) proplist_p, &is_cached,
-                                 ffd->properties_cache, &key, result_pool));
-          if (is_cached)
-            return SVN_NO_ERROR;
-        }
-
-      proplist = apr_hash_make(result_pool);
-      SVN_ERR(svn_fs_x__get_contents(&stream, fs, noderev->prop_rep, FALSE,
-                                     scratch_pool));
-      err = svn_hash_read2(proplist, stream, SVN_HASH_TERMINATOR,
-                           result_pool);
-      if (err)
-        {
-          svn_string_t *id_str = svn_fs_x__id_unparse(&noderev->noderev_id,
-                                                      scratch_pool);
-
-          err = svn_error_compose_create(err, svn_stream_close(stream));
-          return svn_error_quick_wrapf(err,
-                   _("malformed property list for node-revision '%s'"),
-                   id_str->data);
-        }
+      SVN_ERR(svn_cache__get((void **) proplist, &is_cached,
+                             ffd->properties_cache, &key, result_pool));
+      if (is_cached)
+        return SVN_NO_ERROR;
 
-      SVN_ERR(svn_stream_close(stream));
+      SVN_ERR(svn_fs_x__get_contents(&stream, fs, rep, FALSE, scratch_pool));
+      SVN_ERR(svn_string_from_stream2(&content, stream, rep->expanded_size,
+                                      result_pool));
+
+      SVN_ERR_W(svn_fs_x__parse_properties(proplist, content, result_pool),
+                apr_psprintf(scratch_pool,
+                    "malformed property list for node-revision '%s'",
+                    svn_fs_x__id_unparse(&noderev->noderev_id,
+                                         scratch_pool)->data));
 
-      if (SVN_IS_VALID_REVNUM(rep->id.change_set))
-        SVN_ERR(svn_cache__set(ffd->properties_cache, &key, proplist,
-                               scratch_pool));
+      SVN_ERR(svn_cache__set(ffd->properties_cache, &key, *proplist,
+                             scratch_pool));
     }
   else
     {
       /* return an empty prop list if the node doesn't have any props */
-      proplist = apr_hash_make(result_pool);
+      *proplist = apr_hash_make(result_pool);
     }
 
-  *proplist_p = proplist;
-
   return SVN_NO_ERROR;
 }
 
@@ -3318,7 +3296,7 @@ block_read(void **result,
               /* if we crossed a block boundary, read the remainder of
                * the last block as well */
               offset = entry->offset + entry->size;
-              if (offset > block_start + ffd->block_size)
+              if (offset - block_start > ffd->block_size)
                 ++run_count;
 
               svn_pool_clear(iterpool);

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/fs.h?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/fs.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/fs.h Wed Dec  2 07:55:55 2015
@@ -408,10 +408,6 @@ typedef struct svn_fs_x__data_t
 /*** Filesystem Transaction ***/
 typedef struct svn_fs_x__transaction_t
 {
-  /* property list (const char * name, svn_string_t * value).
-     may be NULL if there are no properties.  */
-  apr_hash_t *proplist;
-
   /* revision upon which this txn is base.  (unfinished only) */
   svn_revnum_t base_rev;
 

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/fs_x.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/fs_x.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/fs_x.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/fs_x.c Wed Dec  2 07:55:55 2015
@@ -33,6 +33,7 @@
 
 #include "cached_data.h"
 #include "id.h"
+#include "low_level.h"
 #include "rep-cache.h"
 #include "revprops.h"
 #include "transaction.h"
@@ -935,12 +936,13 @@ write_revision_zero(svn_fs_t *fs,
 
   revprops = svn_stringbuf_create_empty(scratch_pool);
   stream = svn_stream_from_stringbuf(revprops, scratch_pool);
-  SVN_ERR(svn_hash_write2(proplist, stream, SVN_HASH_TERMINATOR,
-                          scratch_pool));
+  SVN_ERR(svn_fs_x__write_properties(stream, proplist, scratch_pool));
   SVN_ERR(svn_stream_close(stream));
 
-  SVN_ERR(svn_io_file_create(svn_fs_x__path_revprops(fs, 0, scratch_pool),
-                             revprops->data, scratch_pool));
+  SVN_ERR(svn_io_file_create_bytes(svn_fs_x__path_revprops(fs, 0,
+                                                           scratch_pool),
+                                   revprops->data, revprops->len,
+                                   scratch_pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/index.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/index.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/index.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/index.c Wed Dec  2 07:55:55 2015
@@ -1932,7 +1932,7 @@ svn_fs_x__l2p_get_max_ids(apr_array_head
       apr_uint64_t item_count;
       apr_size_t first_page_index, last_page_index;
 
-      if (revision >= header->first_revision + header->revision_count)
+      if (revision - header->first_revision >= header->revision_count)
         {
           /* need to read the next index. Clear up memory used for the
            * previous one.  Note that intermittent pack runs do not change
@@ -2650,6 +2650,13 @@ read_entry(svn_fs_x__packed_number_strea
         }
     }
 
+  /* Corrupted SIZE values might cause arithmetic overflow.
+   * The same can happen if you copy a repository from a system with 63 bit
+   * file lengths to one with 31 bit file lengths. */
+  if ((apr_uint64_t)entry.offset + (apr_uint64_t)entry.size > off_t_max)
+    return svn_error_create(SVN_ERR_FS_INDEX_OVERFLOW , NULL,
+                            _("P2L index entry size overflow."));
+
   APR_ARRAY_PUSH(result, svn_fs_x__p2l_entry_t) = entry;
   *item_offset += entry.size;
 

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.c Wed Dec  2 07:55:55 2015
@@ -1146,3 +1146,107 @@ svn_fs_x__write_changes(svn_stream_t *st
   return SVN_NO_ERROR;
 }
 
+svn_error_t *
+svn_fs_x__parse_properties(apr_hash_t **properties,
+                           svn_string_t *content,
+                           apr_pool_t *result_pool)
+{
+  const apr_byte_t *p = (const apr_byte_t *)content->data;
+  const apr_byte_t *end = p + content->len;
+  apr_uint64_t count;
+
+  *properties = apr_hash_make(result_pool);
+
+  /* Extract the number of properties we are expected to read. */
+  p = svn__decode_uint(&count, p, end);
+
+  /* Read all the properties we find.
+     Because prop-name and prop-value are nicely NUL-terminated
+     sub-strings of CONTENT, we can simply reference them there.
+     I.e. there is no need to copy them around.
+   */
+  while (p < end)
+    {
+      apr_uint64_t value_len;
+      svn_string_t *value;
+
+      const char *key = (const char *)p;
+
+      /* Note that this may never overflow / segfault because
+         CONTENT itself is NUL-terminated. */
+      apr_size_t key_len = strlen(key);
+      p += key_len + 1;
+      if (key[key_len])
+        return svn_error_createf(SVN_ERR_FS_CORRUPT_PROPLIST, NULL,
+                                 "Property name not NUL terminated");
+
+      if (p >= end)
+        return svn_error_createf(SVN_ERR_FS_CORRUPT_PROPLIST, NULL,
+                                 "Property value missing");
+      p = svn__decode_uint(&value_len, p, end);
+      if (value_len >= (end - p))
+        return svn_error_createf(SVN_ERR_FS_CORRUPT_PROPLIST, NULL,
+                                 "Property value too long");
+
+      value = apr_pcalloc(result_pool, sizeof(*value));
+      value->data = (const char *)p;
+      value->len = (apr_size_t)value_len;
+      if (p[value->len])
+        return svn_error_createf(SVN_ERR_FS_CORRUPT_PROPLIST, NULL,
+                                 "Property value not NUL terminated");
+
+      p += value->len + 1;
+
+      apr_hash_set(*properties, key, key_len, value);
+    }
+
+  /* Check that we read the expected number of properties. */
+  if ((apr_uint64_t)apr_hash_count(*properties) != count)
+    return svn_error_createf(SVN_ERR_FS_CORRUPT_PROPLIST, NULL,
+                             "Property count mismatch");
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_x__write_properties(svn_stream_t *stream,
+                           apr_hash_t *proplist,
+                           apr_pool_t *scratch_pool)
+{
+  apr_byte_t buffer[SVN__MAX_ENCODED_UINT_LEN];
+  apr_size_t len;
+  apr_hash_index_t *hi;
+
+  /* Write the number of properties in this list. */
+  len = svn__encode_uint(buffer, apr_hash_count(proplist)) - buffer;
+  SVN_ERR(svn_stream_write(stream, (const char *)buffer, &len));
+
+  /* Serialize each property as follows:
+     <Prop-name> <NUL>
+     <Value-len> <Prop-value> <NUL>
+   */
+  for (hi = apr_hash_first(scratch_pool, proplist);
+       hi;
+       hi = apr_hash_next(hi))
+    {
+      const char *key;
+      apr_size_t key_len;
+      svn_string_t *value;
+      apr_hash_this(hi, (const void **)&key, (apr_ssize_t *)&key_len,
+                    (void **)&value);
+
+      /* Include the terminating NUL. */
+      ++key_len;
+      SVN_ERR(svn_stream_write(stream, key, &key_len));
+
+      len = svn__encode_uint(buffer, value->len) - buffer;
+      SVN_ERR(svn_stream_write(stream, (const char *)buffer, &len));
+      SVN_ERR(svn_stream_write(stream, value->data, &value->len));
+
+      /* Terminate with NUL. */
+      len = 1;
+      SVN_ERR(svn_stream_write(stream, "", &len));
+    }
+
+  return SVN_NO_ERROR;
+}

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.h?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/low_level.h Wed Dec  2 07:55:55 2015
@@ -210,6 +210,23 @@ svn_fs_x__write_changes(svn_stream_t *st
                         svn_boolean_t terminate_list,
                         apr_pool_t *scratch_pool);
 
+/* Parse the property list serialized in CONTENT and return it in
+   *PROPERTIES, allocated from RESULT_POOL.  CONTENT must remain
+   valid at least until the next cleanup of RESULT_POOL.
+ */
+svn_error_t *
+svn_fs_x__parse_properties(apr_hash_t **properties,
+                           svn_string_t *content,
+                           apr_pool_t *result_pool);
+
+/* Write the property list PROPLIST to STREAM in serialized format.
+   Use SCRATCH_POOL for temporary allocations.
+ */
+svn_error_t *
+svn_fs_x__write_properties(svn_stream_t *stream,
+                           apr_hash_t *proplist,
+                           apr_pool_t *scratch_pool);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/pack.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/pack.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/pack.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/pack.c Wed Dec  2 07:55:55 2015
@@ -1958,7 +1958,8 @@ pack_log_addressed(svn_fs_t *fs,
 
   /* pack revisions in ranges that don't exceed MAX_MEM */
   for (i = 0; i < max_ids->nelts; ++i)
-    if (APR_ARRAY_IDX(max_ids, i, apr_uint64_t) + item_count <= max_items)
+    if (   APR_ARRAY_IDX(max_ids, i, apr_uint64_t)
+        <= (apr_uint64_t)max_items - item_count)
       {
         context.end_rev++;
       }

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.c Wed Dec  2 07:55:55 2015
@@ -26,8 +26,10 @@
 #include "svn_pools.h"
 #include "svn_hash.h"
 #include "svn_dirent_uri.h"
+#include "svn_sorts.h"
 
 #include "fs_x.h"
+#include "low_level.h"
 #include "revprops.h"
 #include "util.h"
 #include "transaction.h"
@@ -411,13 +413,10 @@ parse_revprop(apr_hash_t **properties,
               apr_pool_t *result_pool,
               apr_pool_t *scratch_pool)
 {
-  svn_stream_t *stream = svn_stream_from_string(content, scratch_pool);
-  *properties = apr_hash_make(result_pool);
-
-  SVN_ERR_W(svn_hash_read2(*properties, stream, SVN_HASH_TERMINATOR,
-                           result_pool),
+  SVN_ERR_W(svn_fs_x__parse_properties(properties, content, result_pool),
             apr_psprintf(scratch_pool, "Failed to parse revprops for r%ld.",
                          revision));
+
   if (has_revprop_cache(fs, scratch_pool))
     {
       svn_fs_x__data_t *ffd = fs->fsap_data;
@@ -467,9 +466,14 @@ read_non_packed_revprop(apr_hash_t **pro
     }
 
   if (content)
-    SVN_ERR(parse_revprop(properties, fs, rev,
-                          svn_stringbuf__morph_into_string(content),
-                          result_pool, iterpool));
+    {
+      /* The contents string becomes part of the *PROPERTIES structure, i.e.
+       * we must make sure it lives at least as long as the latter. */
+      svn_string_t *as_string = svn_string_create_from_buf(content,
+                                                           result_pool);
+      SVN_ERR(parse_revprop(properties, fs, rev, as_string,
+                            result_pool, iterpool));
+    }
 
   svn_pool_clear(iterpool);
 
@@ -727,12 +731,11 @@ parse_packed_revprops(svn_fs_t *fs,
                       apr_pool_t *result_pool,
                       apr_pool_t *scratch_pool)
 {
-  svn_stream_t *stream;
-  apr_int64_t first_rev, count, i;
-  apr_off_t offset;
-  const char *header_end;
+  apr_uint64_t first_rev, count, i;
+  apr_size_t offset;
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   svn_boolean_t cache_all = has_revprop_cache(fs, scratch_pool);
+  const apr_byte_t *p, *end;
 
   /* decompress (even if the data is only "stored", there is still a
    * length header to remove) */
@@ -742,10 +745,10 @@ parse_packed_revprops(svn_fs_t *fs,
                           uncompressed, APR_SIZE_MAX));
 
   /* read first revision number and number of revisions in the pack */
-  stream = svn_stream_from_stringbuf(uncompressed, scratch_pool);
-  SVN_ERR(svn_fs_x__read_number_from_stream(&first_rev, NULL, stream,
-                                            iterpool));
-  SVN_ERR(svn_fs_x__read_number_from_stream(&count, NULL, stream, iterpool));
+  p = (apr_byte_t *)uncompressed->data;
+  end = p + uncompressed->len;
+  p = svn__decode_uint(&first_rev, p, end);
+  p = svn__decode_uint(&count, p, end);
 
   /* Check revision range for validity. */
   if (   !same_shard(fs, revprops->revision, first_rev)
@@ -767,51 +770,65 @@ parse_packed_revprops(svn_fs_t *fs,
                                " starts at non-packed revisions r%ld"),
                              revprops->revision, (svn_revnum_t)first_rev);
 
+  /* Read the item sizes from the header. */
+  revprops->sizes = apr_array_make(result_pool, (int)count, sizeof(offset));
+  revprops->offsets = apr_array_make(result_pool, (int)count, sizeof(offset));
+
+  for (i = 0, offset = 0, revprops->total_size = 0; i < count; ++i)
+    {
+      apr_uint64_t size64;
+      apr_size_t size;
+
+      /* read & check the serialized size */
+      p = svn__decode_uint(&size64, p, end);
+      if (size64 > uncompressed->len - offset)
+        return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
+                                "Packed revprop size exceeds pack file size");
+
+      size = (apr_size_t)size64;
+
+      /* fill REVPROPS data structures */
+      APR_ARRAY_PUSH(revprops->sizes, apr_size_t) = size;
+      APR_ARRAY_PUSH(revprops->offsets, apr_size_t) = offset;
+      revprops->total_size += size;
+
+      offset += size;
+    }
+
   /* make PACKED_REVPROPS point to the first char after the header.
    * This is where the serialized revprops are. */
-  header_end = strstr(uncompressed->data, "\n\n");
-  if (header_end == NULL)
-    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                            _("Header end not found"));
-
-  offset = header_end - uncompressed->data + 2;
+  offset = p - (apr_byte_t *)uncompressed->data;
 
   revprops->packed_revprops = svn_stringbuf_create_empty(result_pool);
   revprops->packed_revprops->data = uncompressed->data + offset;
-  revprops->packed_revprops->len = (apr_size_t)(uncompressed->len - offset);
-  revprops->packed_revprops->blocksize = (apr_size_t)(uncompressed->blocksize - offset);
+  revprops->packed_revprops->len = uncompressed->len - offset;
+  revprops->packed_revprops->blocksize = uncompressed->blocksize - offset;
+
+  /* Verify that the last offset size does not extend beyond file sans
+   * header (we only checked against the full file contents). */
+  if (revprops->total_size > revprops->packed_revprops->len)
+    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
+                            "Packed revprop size exceeds pack file size");
 
   /* STREAM still points to the first entry in the sizes list. */
   SVN_ERR_ASSERT(revprops->entry.start_rev = (svn_revnum_t)first_rev);
-  if (read_all)
-    {
-      /* Init / construct REVPROPS members. */
-      revprops->sizes = apr_array_make(result_pool, (int)count,
-                                       sizeof(offset));
-      revprops->offsets = apr_array_make(result_pool, (int)count,
-                                         sizeof(offset));
-    }
 
   /* Now parse, revision by revision, the size and content of each
    * revisions' revprops. */
-  for (i = 0, offset = 0, revprops->total_size = 0; i < count; ++i)
+  for (i = 0, offset = 0; i < count; ++i)
     {
-      apr_int64_t size;
       svn_string_t serialized;
+
       svn_revnum_t revision = (svn_revnum_t)(first_rev + i);
-      svn_pool_clear(iterpool);
+      apr_size_t size = APR_ARRAY_IDX(revprops->sizes, (int)i, apr_size_t);
+      offset = APR_ARRAY_IDX(revprops->offsets, (int)i, apr_size_t);
 
-      /* read & check the serialized size */
-      SVN_ERR(svn_fs_x__read_number_from_stream(&size, NULL, stream,
-                                                iterpool));
-      if (size + offset > (apr_int64_t)revprops->packed_revprops->len)
-        return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
-                        _("Packed revprop size exceeds pack file size"));
+      svn_pool_clear(iterpool);
 
-      /* Parse this revprops list, if necessary */
       serialized.data = revprops->packed_revprops->data + offset;
-      serialized.len = (apr_size_t)size;
+      serialized.len = size;
 
+      /* Parse this revprops list, if necessary */
       if (revision == revprops->revision)
         {
           /* Parse (and possibly cache) the one revprop list we care about. */
@@ -830,18 +847,10 @@ parse_packed_revprops(svn_fs_t *fs,
           SVN_ERR(parse_revprop(&properties, fs, revision, &serialized,
                                 iterpool, iterpool));
         }
-
-      if (read_all)
-        {
-          /* fill REVPROPS data structures */
-          APR_ARRAY_PUSH(revprops->sizes, apr_off_t) = serialized.len;
-          APR_ARRAY_PUSH(revprops->offsets, apr_off_t) = offset;
-        }
-      revprops->total_size += serialized.len;
-
-      offset += serialized.len;
     }
 
+  svn_pool_destroy(iterpool);
+
   return SVN_NO_ERROR;
 }
 
@@ -1022,9 +1031,9 @@ write_non_packed_revprop(const char **fi
   *tmp_path = apr_pstrcat(result_pool, *final_path, ".tmp", SVN_VA_NULL);
   SVN_ERR(svn_fs_x__batch_fsync_open_file(&file, batch, *tmp_path,
                                           scratch_pool));
+
   stream = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
-  SVN_ERR(svn_hash_write2(proplist, stream, SVN_HASH_TERMINATOR,
-                          scratch_pool));
+  SVN_ERR(svn_fs_x__write_properties(stream, proplist, scratch_pool));
   SVN_ERR(svn_stream_close(stream));
 
   return SVN_NO_ERROR;
@@ -1087,6 +1096,20 @@ switch_to_new_revprop(svn_fs_t *fs,
   return SVN_NO_ERROR;
 }
 
+/* Write VALUE to STREAM using 7/8b encoding. */
+static svn_error_t *
+write_encoded_uint(svn_stream_t *stream,
+                   apr_uint64_t value)
+{
+  apr_byte_t buffer[SVN__MAX_ENCODED_UINT_LEN];
+  apr_size_t len;
+
+  len = svn__encode_uint(buffer, value) - buffer;
+  SVN_ERR(svn_stream_write(stream, (const char *)buffer, &len));
+
+  return SVN_NO_ERROR;
+}
+
 /* Write a pack file header to STREAM that starts at revision START_REVISION
  * and contains the indexes [START,END) of SIZES.
  */
@@ -1098,32 +1121,17 @@ serialize_revprops_header(svn_stream_t *
                           int end,
                           apr_pool_t *scratch_pool)
 {
-  apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   int i;
-
   SVN_ERR_ASSERT(start < end);
 
   /* start revision and entry count */
-  SVN_ERR(svn_stream_printf(stream, scratch_pool, "%ld\n", start_revision));
-  SVN_ERR(svn_stream_printf(stream, scratch_pool, "%d\n", end - start));
+  SVN_ERR(write_encoded_uint(stream, start_revision));
+  SVN_ERR(write_encoded_uint(stream, end - start));
 
   /* the sizes array */
   for (i = start; i < end; ++i)
-    {
-      /* Non-standard pool usage.
-       *
-       * We only allocate a few bytes each iteration -- even with a
-       * million iterations we would still be in good shape memory-wise.
-       */
-      apr_off_t size = APR_ARRAY_IDX(sizes, i, apr_off_t);
-      SVN_ERR(svn_stream_printf(stream, iterpool, "%" APR_OFF_T_FMT "\n",
-                                size));
-    }
-
-  /* the double newline char indicates the end of the header */
-  SVN_ERR(svn_stream_printf(stream, iterpool, "\n"));
+    SVN_ERR(write_encoded_uint(stream, APR_ARRAY_IDX(sizes, i, apr_size_t)));
 
-  svn_pool_destroy(iterpool);
   return SVN_NO_ERROR;
 }
 
@@ -1144,7 +1152,7 @@ repack_revprops(svn_fs_t *fs,
                 int end,
                 int changed_index,
                 svn_stringbuf_t *new_serialized,
-                apr_off_t new_total_size,
+                apr_size_t new_total_size,
                 apr_file_t *file,
                 apr_pool_t *scratch_pool)
 {
@@ -1175,10 +1183,8 @@ repack_revprops(svn_fs_t *fs,
       }
     else
       {
-        apr_size_t size
-            = (apr_size_t)APR_ARRAY_IDX(revprops->sizes, i, apr_off_t);
-        apr_size_t offset
-            = (apr_size_t)APR_ARRAY_IDX(revprops->offsets, i, apr_off_t);
+        apr_size_t size = APR_ARRAY_IDX(revprops->sizes, i, apr_size_t);
+        apr_size_t offset = APR_ARRAY_IDX(revprops->offsets, i, apr_size_t);
 
         SVN_ERR(svn_stream_write(stream,
                                  revprops->packed_revprops->data + offset,
@@ -1281,7 +1287,7 @@ write_packed_revprop(const char **final_
   svn_stream_t *stream;
   apr_file_t *file;
   svn_stringbuf_t *serialized;
-  apr_off_t new_total_size;
+  apr_size_t new_total_size;
   int changed_index;
 
   /* read the current revprop generation. This value will not change
@@ -1296,8 +1302,7 @@ write_packed_revprop(const char **final_
   /* serialize the new revprops */
   serialized = svn_stringbuf_create_empty(scratch_pool);
   stream = svn_stream_from_stringbuf(serialized, scratch_pool);
-  SVN_ERR(svn_hash_write2(proplist, stream, SVN_HASH_TERMINATOR,
-                          scratch_pool));
+  SVN_ERR(svn_fs_x__write_properties(stream, proplist, scratch_pool));
   SVN_ERR(svn_stream_close(stream));
 
   /* calculate the size of the new data */
@@ -1306,7 +1311,7 @@ write_packed_revprop(const char **final_
                  + serialized->len
                  + (revprops->offsets->nelts + 2) * SVN_INT64_BUFFER_SIZE;
 
-  APR_ARRAY_IDX(revprops->sizes, changed_index, apr_off_t) = serialized->len;
+  APR_ARRAY_IDX(revprops->sizes, changed_index, apr_size_t) = serialized->len;
 
   /* can we put the new data into the same pack as the before? */
   if (   new_total_size < ffd->revprop_pack_size
@@ -1331,23 +1336,23 @@ write_packed_revprop(const char **final_
 
       int left = 0;
       int right = revprops->sizes->nelts - 1;
-      apr_off_t left_size = 2 * SVN_INT64_BUFFER_SIZE;
-      apr_off_t right_size = 2 * SVN_INT64_BUFFER_SIZE;
+      apr_size_t left_size = 2 * SVN_INT64_BUFFER_SIZE;
+      apr_size_t right_size = 2 * SVN_INT64_BUFFER_SIZE;
 
       /* let left and right side grow such that their size difference
        * is minimal after each step. */
       while (left <= right)
-        if (  left_size + APR_ARRAY_IDX(revprops->sizes, left, apr_off_t)
-            < right_size + APR_ARRAY_IDX(revprops->sizes, right, apr_off_t))
+        if (  left_size + APR_ARRAY_IDX(revprops->sizes, left, apr_size_t)
+            < right_size + APR_ARRAY_IDX(revprops->sizes, right, apr_size_t))
           {
-            left_size += APR_ARRAY_IDX(revprops->sizes, left, apr_off_t)
+            left_size += APR_ARRAY_IDX(revprops->sizes, left, apr_size_t)
                       + SVN_INT64_BUFFER_SIZE;
             ++left;
           }
         else
           {
-            right_size += APR_ARRAY_IDX(revprops->sizes, right, apr_off_t)
-                        + SVN_INT64_BUFFER_SIZE;
+            right_size += APR_ARRAY_IDX(revprops->sizes, right, apr_size_t)
+                       + SVN_INT64_BUFFER_SIZE;
             --right;
           }
 
@@ -1621,7 +1626,7 @@ svn_fs_x__pack_revprops_shard(svn_fs_t *
                               const char *shard_path,
                               apr_int64_t shard,
                               int max_files_per_dir,
-                              apr_off_t max_pack_size,
+                              apr_int64_t max_pack_size,
                               int compression_level,
                               svn_fs_x__batch_fsync_t *batch,
                               svn_cancel_func_t cancel_func,
@@ -1631,11 +1636,15 @@ svn_fs_x__pack_revprops_shard(svn_fs_t *
   const char *manifest_file_path, *pack_filename = NULL;
   apr_file_t *manifest_file;
   svn_revnum_t start_rev, end_rev, rev;
-  apr_off_t total_size;
+  apr_size_t total_size;
   apr_pool_t *iterpool = svn_pool_create(scratch_pool);
   apr_array_header_t *sizes;
   apr_array_header_t *manifest;
 
+  /* Sanitize config file values. */
+  apr_size_t max_size = (apr_size_t)MIN(MAX(max_pack_size, 1),
+                                        SVN_MAX_OBJECT_SIZE);
+
   /* Some useful paths. */
   manifest_file_path = svn_dirent_join(pack_file_dir, PATH_MANIFEST,
                                        scratch_pool);
@@ -1663,7 +1672,7 @@ svn_fs_x__pack_revprops_shard(svn_fs_t *
     }
 
   /* initialize the revprop size info */
-  sizes = apr_array_make(scratch_pool, max_files_per_dir, sizeof(apr_off_t));
+  sizes = apr_array_make(scratch_pool, max_files_per_dir, sizeof(apr_size_t));
   total_size = 2 * SVN_INT64_BUFFER_SIZE;
 
   manifest = apr_array_make(scratch_pool, 4, sizeof(manifest_entry_t));
@@ -1681,10 +1690,13 @@ svn_fs_x__pack_revprops_shard(svn_fs_t *
       path = svn_fs_x__path_revprops(fs, rev, iterpool);
       SVN_ERR(svn_io_stat(&finfo, path, APR_FINFO_SIZE, iterpool));
 
-      /* if we already have started a pack file and this revprop cannot be
-       * appended to it, write the previous pack file. */
-      if (sizes->nelts != 0 &&
-          total_size + SVN_INT64_BUFFER_SIZE + finfo.size > max_pack_size)
+      /* If we already have started a pack file and this revprop cannot be
+       * appended to it, write the previous pack file.  Note this overflow
+       * check works because we enforced MAX_SIZE <= SVN_MAX_OBJECT_SIZE. */
+      if (sizes->nelts != 0
+          && (   finfo.size > max_size
+              || total_size > max_size
+              || SVN_INT64_BUFFER_SIZE + finfo.size > max_size - total_size))
         {
           SVN_ERR(copy_revprops(fs, pack_file_dir, pack_filename,
                                 shard_path, start_rev, rev-1,
@@ -1710,7 +1722,7 @@ svn_fs_x__pack_revprops_shard(svn_fs_t *
         }
 
       /* add to list of files to put into the current pack file */
-      APR_ARRAY_PUSH(sizes, apr_off_t) = finfo.size;
+      APR_ARRAY_PUSH(sizes, apr_size_t) = finfo.size;
       total_size += SVN_INT64_BUFFER_SIZE + finfo.size;
     }
 

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.h?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/revprops.h Wed Dec  2 07:55:55 2015
@@ -103,7 +103,7 @@ svn_fs_x__pack_revprops_shard(svn_fs_t *
                               const char *shard_path,
                               apr_int64_t shard,
                               int max_files_per_dir,
-                              apr_off_t max_pack_size,
+                              apr_int64_t max_pack_size,
                               int compression_level,
                               svn_fs_x__batch_fsync_t *batch,
                               svn_cancel_func_t cancel_func,

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/transaction.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/transaction.c Wed Dec  2 07:55:55 2015
@@ -1373,16 +1373,16 @@ create_txn(svn_fs_txn_t **txn_p,
   return SVN_NO_ERROR;
 }
 
-/* Store the property list for transaction TXN_ID in PROPLIST.
-   Perform temporary allocations in SCRATCH_POOL. */
+/* Store the property list for transaction TXN_ID in *PROPLIST, allocated
+   from RESULT_POOL. Perform temporary allocations in SCRATCH_POOL. */
 static svn_error_t *
-get_txn_proplist(apr_hash_t *proplist,
+get_txn_proplist(apr_hash_t **proplist,
                  svn_fs_t *fs,
                  svn_fs_x__txn_id_t txn_id,
+                 apr_pool_t *result_pool,
                  apr_pool_t *scratch_pool)
 {
-  svn_stream_t *stream;
-  svn_error_t *err;
+  svn_stringbuf_t *content;
 
   /* Check for issue #3696. (When we find and fix the cause, we can change
    * this to an assertion.) */
@@ -1392,23 +1392,20 @@ get_txn_proplist(apr_hash_t *proplist,
                               "passed to get_txn_proplist()"));
 
   /* Open the transaction properties file. */
-  SVN_ERR(svn_stream_open_readonly(&stream,
+  SVN_ERR(svn_stringbuf_from_file2(&content,
                                    svn_fs_x__path_txn_props(fs, txn_id,
                                                             scratch_pool),
-                                   scratch_pool, scratch_pool));
+                                   result_pool));
 
   /* Read in the property list. */
-  err = svn_hash_read2(proplist, stream, SVN_HASH_TERMINATOR,
-                       scratch_pool);
-  if (err)
-    {
-      err = svn_error_compose_create(err, svn_stream_close(stream));
-      return svn_error_quick_wrapf(err,
-               _("malformed property list in transaction '%s'"),
-               svn_fs_x__path_txn_props(fs, txn_id, scratch_pool));
-    }
+  SVN_ERR_W(svn_fs_x__parse_properties(proplist,
+                                   svn_stringbuf__morph_into_string(content),
+                                   result_pool),
+            apr_psprintf(scratch_pool,
+                         _("malformed property list in transaction '%s'"),
+                         svn_fs_x__path_txn_props(fs, txn_id, scratch_pool)));
 
-  return svn_stream_close(stream);
+  return SVN_NO_ERROR;
 }
 
 /* Save the property list PROPS as the revprops for transaction TXN_ID
@@ -1428,7 +1425,7 @@ set_txn_proplist(svn_fs_t *fs,
                                                         scratch_pool),
                                  svn_io_file_del_none,
                                  scratch_pool, scratch_pool));
-  SVN_ERR(svn_hash_write2(props, stream, SVN_HASH_TERMINATOR, scratch_pool));
+  SVN_ERR(svn_fs_x__write_properties(stream, props, scratch_pool));
   SVN_ERR(svn_stream_close(stream));
 
   /* Replace the old file with the new one. */
@@ -1466,11 +1463,11 @@ svn_fs_x__change_txn_props(svn_fs_txn_t
 {
   fs_txn_data_t *ftd = txn->fsap_data;
   apr_pool_t *subpool = svn_pool_create(scratch_pool);
-  apr_hash_t *txn_prop = apr_hash_make(subpool);
+  apr_hash_t *txn_prop;
   int i;
   svn_error_t *err;
 
-  err = get_txn_proplist(txn_prop, txn->fs, ftd->txn_id, subpool);
+  err = get_txn_proplist(&txn_prop, txn->fs, ftd->txn_id, subpool, subpool);
   /* Here - and here only - we need to deal with the possibility that the
      transaction property file doesn't yet exist.  The rest of the
      implementation assumes that the file exists, but we're called to set the
@@ -1511,9 +1508,6 @@ svn_fs_x__get_txn(svn_fs_x__transaction_
   svn_fs_x__id_t root_id;
 
   txn = apr_pcalloc(pool, sizeof(*txn));
-  txn->proplist = apr_hash_make(pool);
-
-  SVN_ERR(get_txn_proplist(txn->proplist, fs, txn_id, pool));
   svn_fs_x__init_txn_root(&root_id, txn_id);
 
   SVN_ERR(svn_fs_x__get_node_revision(&noderev, fs, &root_id, pool, pool));
@@ -1585,12 +1579,17 @@ allocate_item_index(apr_uint64_t *item_i
   SVN_ERR(svn_io_file_open(&file,
                             svn_fs_x__path_txn_item_index(fs, txn_id,
                                                           scratch_pool),
-                            APR_READ | APR_WRITE
-                            | APR_CREATE | APR_BUFFERED,
+                            APR_READ | APR_WRITE | APR_CREATE,
                             APR_OS_DEFAULT, scratch_pool));
   SVN_ERR(svn_io_file_read_full2(file, buffer, sizeof(buffer)-1,
                                   &bytes_read, &eof, scratch_pool));
-  if (bytes_read)
+
+  /* Item index file should be shorter than SVN_INT64_BUFFER_SIZE,
+     otherwise we truncate data. */
+  if (!eof)
+    return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
+                            _("Unexpected itemidx file length"));
+  else if (bytes_read)
     SVN_ERR(svn_cstring_atoui64(item_index, buffer));
   else
     *item_index = SVN_FS_X__ITEM_INDEX_FIRST_USER;
@@ -2678,7 +2677,7 @@ svn_fs_x__set_proplist(svn_fs_t *fs,
                            APR_WRITE | APR_CREATE | APR_TRUNCATE
                            | APR_BUFFERED, APR_OS_DEFAULT, scratch_pool));
   out = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
-  SVN_ERR(svn_hash_write2(proplist, out, SVN_HASH_TERMINATOR, scratch_pool));
+  SVN_ERR(svn_fs_x__write_properties(out, proplist, scratch_pool));
   SVN_ERR(svn_io_file_close(file, scratch_pool));
 
   /* Mark the node-rev's prop rep as mutable, if not already done. */
@@ -2745,7 +2744,7 @@ write_hash_to_stream(svn_stream_t *strea
                      apr_pool_t *scratch_pool)
 {
   apr_hash_t *hash = baton;
-  SVN_ERR(svn_hash_write2(hash, stream, SVN_HASH_TERMINATOR, scratch_pool));
+  SVN_ERR(svn_fs_x__write_properties(stream, hash, scratch_pool));
 
   return SVN_NO_ERROR;
 }
@@ -3465,7 +3464,7 @@ write_final_revprop(const char **path,
 
   /* Write the new contents to the final revprops file. */
   stream = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
-  SVN_ERR(svn_hash_write2(props, stream, SVN_HASH_TERMINATOR, scratch_pool));
+  SVN_ERR(svn_fs_x__write_properties(stream, props, scratch_pool));
   SVN_ERR(svn_stream_close(stream));
 
   return SVN_NO_ERROR;
@@ -4029,10 +4028,8 @@ svn_fs_x__txn_proplist(apr_hash_t **tabl
                        svn_fs_txn_t *txn,
                        apr_pool_t *pool)
 {
-  apr_hash_t *proplist = apr_hash_make(pool);
-  SVN_ERR(get_txn_proplist(proplist, txn->fs, svn_fs_x__txn_get_id(txn),
-                           pool));
-  *table_p = proplist;
+  SVN_ERR(get_txn_proplist(table_p, txn->fs, svn_fs_x__txn_get_id(txn),
+                           pool, pool));
 
   return SVN_NO_ERROR;
 }

Modified: subversion/branches/ra-git/subversion/libsvn_fs_x/tree.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_fs_x/tree.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_fs_x/tree.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_fs_x/tree.c Wed Dec  2 07:55:55 2015
@@ -2200,23 +2200,18 @@ x_contents_changed(svn_boolean_t *change
       (SVN_ERR_FS_GENERAL, NULL,
        _("Cannot compare file contents between two different filesystems"));
 
-  /* Check that both paths are files. */
-  {
-    svn_node_kind_t kind;
-
-    SVN_ERR(svn_fs_x__check_path(&kind, root1, path1, subpool));
-    if (kind != svn_node_file)
-      return svn_error_createf
-        (SVN_ERR_FS_GENERAL, NULL, _("'%s' is not a file"), path1);
-
-    SVN_ERR(svn_fs_x__check_path(&kind, root2, path2, subpool));
-    if (kind != svn_node_file)
-      return svn_error_createf
-        (SVN_ERR_FS_GENERAL, NULL, _("'%s' is not a file"), path2);
-  }
-
   SVN_ERR(svn_fs_x__get_dag_node(&node1, root1, path1, subpool, subpool));
+  /* Make sure that path is file. */
+  if (svn_fs_x__dag_node_kind(node1) != svn_node_file)
+    return svn_error_createf
+      (SVN_ERR_FS_GENERAL, NULL, _("'%s' is not a file"), path1);
+
   SVN_ERR(svn_fs_x__get_temp_dag_node(&node2, root2, path2, subpool));
+  /* Make sure that path is file. */
+  if (svn_fs_x__dag_node_kind(node2) != svn_node_file)
+    return svn_error_createf
+      (SVN_ERR_FS_GENERAL, NULL, _("'%s' is not a file"), path2);
+
   SVN_ERR(svn_fs_x__dag_things_different(NULL, changed_p, node1, node2,
                                          strict, subpool));
 

Modified: subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.c Wed Dec  2 07:55:55 2015
@@ -81,7 +81,7 @@ static const struct ra_lib_defn {
   {
     "svn",
     svn_schemes,
-#ifdef SVN_LIBSVN_CLIENT_LINKS_RA_SVN
+#ifdef SVN_LIBSVN_RA_LINKS_RA_SVN
     svn_ra_svn__init,
     svn_ra_svn__deprecated_init
 #endif
@@ -90,7 +90,7 @@ static const struct ra_lib_defn {
   {
     "local",
     local_schemes,
-#ifdef SVN_LIBSVN_CLIENT_LINKS_RA_LOCAL
+#ifdef SVN_LIBSVN_RA_LINKS_RA_LOCAL
     svn_ra_local__init,
     svn_ra_local__deprecated_init
 #endif
@@ -99,7 +99,7 @@ static const struct ra_lib_defn {
   {
     "serf",
     dav_schemes,
-#ifdef SVN_LIBSVN_CLIENT_LINKS_RA_SERF
+#ifdef SVN_LIBSVN_RA_LINKS_RA_SERF
     svn_ra_serf__init,
     svn_ra_serf__deprecated_init
 #endif
@@ -419,6 +419,9 @@ svn_error_t *svn_ra_open4(svn_ra_session
       return SVN_NO_ERROR;
     }
 
+  if (vtable->set_svn_ra_open)
+    SVN_ERR(vtable->set_svn_ra_open(session, svn_ra_open4));
+
   /* Check the UUID. */
   if (uuid)
     {
@@ -477,6 +480,9 @@ svn_ra__dup_session(svn_ra_session_t **n
                                            result_pool,
                                            scratch_pool));
 
+  if (session->vtable->set_svn_ra_open)
+    SVN_ERR(session->vtable->set_svn_ra_open(session, svn_ra_open4));
+
   *new_session = session;
   return SVN_NO_ERROR;
 }
@@ -1537,7 +1543,7 @@ svn_ra_get_ra_library(svn_ra_plugin_t **
    implementation for svn_ra_foo_init which returns a "not implemented"
    error. */
 
-#ifndef SVN_LIBSVN_CLIENT_LINKS_RA_NEON
+#ifndef SVN_LIBSVN_RA_LINKS_RA_NEON
 svn_error_t *
 svn_ra_dav_init(int abi_version,
                 apr_pool_t *pool,
@@ -1545,9 +1551,9 @@ svn_ra_dav_init(int abi_version,
 {
   return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, NULL, NULL);
 }
-#endif /* ! SVN_LIBSVN_CLIENT_LINKS_RA_NEON */
+#endif /* ! SVN_LIBSVN_RA_LINKS_RA_NEON */
 
-#ifndef SVN_LIBSVN_CLIENT_LINKS_RA_SVN
+#ifndef SVN_LIBSVN_RA_LINKS_RA_SVN
 svn_error_t *
 svn_ra_svn_init(int abi_version,
                 apr_pool_t *pool,
@@ -1555,9 +1561,9 @@ svn_ra_svn_init(int abi_version,
 {
   return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, NULL, NULL);
 }
-#endif /* ! SVN_LIBSVN_CLIENT_LINKS_RA_SVN */
+#endif /* ! SVN_LIBSVN_RA_LINKS_RA_SVN */
 
-#ifndef SVN_LIBSVN_CLIENT_LINKS_RA_LOCAL
+#ifndef SVN_LIBSVN_RA_LINKS_RA_LOCAL
 svn_error_t *
 svn_ra_local_init(int abi_version,
                   apr_pool_t *pool,
@@ -1565,9 +1571,9 @@ svn_ra_local_init(int abi_version,
 {
   return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, NULL, NULL);
 }
-#endif /* ! SVN_LIBSVN_CLIENT_LINKS_RA_LOCAL */
+#endif /* ! SVN_LIBSVN_RA_LINKS_RA_LOCAL */
 
-#ifndef SVN_LIBSVN_CLIENT_LINKS_RA_SERF
+#ifndef SVN_LIBSVN_RA_LINKS_RA_SERF
 svn_error_t *
 svn_ra_serf_init(int abi_version,
                  apr_pool_t *pool,
@@ -1575,9 +1581,9 @@ svn_ra_serf_init(int abi_version,
 {
   return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, NULL, NULL);
 }
-#endif /* ! SVN_LIBSVN_CLIENT_LINKS_RA_SERF */
+#endif /* ! SVN_LIBSVN_RA_LINKS_RA_SERF */
 
-#ifndef SVN_LIBSVN_CLIENT_LINKS_RA_GIT
+#ifndef SVN_LIBSVN_RA_LINKS_RA_GIT
 svn_error_t *
 svn_ra_git_init(int abi_version,
                  apr_pool_t *pool,
@@ -1585,4 +1591,4 @@ svn_ra_git_init(int abi_version,
 {
   return svn_error_create(SVN_ERR_RA_NOT_IMPLEMENTED, NULL, NULL);
 }
-#endif /* ! SVN_LIBSVN_CLIENT_LINKS_RA_GIT */
+#endif /* ! SVN_LIBSVN_RA_LINKS_RA_GIT */

Modified: subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.h
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.h?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.h (original)
+++ subversion/branches/ra-git/subversion/libsvn_ra/ra_loader.h Wed Dec  2 07:55:55 2015
@@ -38,6 +38,17 @@
 extern "C" {
 #endif
 
+/* Prototype of most recent version of svn_ra_openX() api, optionally
+   handed to the ra api to allow opening other ra sessions. */
+typedef svn_error_t * (*svn_ra__open_func_t)(svn_ra_session_t **session_p,
+                                              const char **corrected_url,
+                                              const char *repos_URL,
+                                              const char *uuid,
+                                              const svn_ra_callbacks2_t *callbacks,
+                                              void *callback_baton,
+                                              apr_hash_t *config,
+                                              apr_pool_t *pool);
+
 /* The RA layer vtable. */
 typedef struct svn_ra__vtable_t {
   /* This field should always remain first in the vtable. */
@@ -308,10 +319,6 @@ typedef struct svn_ra__vtable_t {
                                   svn_revnum_t end_revision,
                                   svn_revnum_t *revision_deleted,
                                   apr_pool_t *pool);
-
-  /* See svn_ra__register_editor_shim_callbacks() */
-  svn_error_t *(*register_editor_shim_callbacks)(svn_ra_session_t *session,
-                                    svn_delta_shim_callbacks_t *callbacks);
   /* See svn_ra_get_inherited_props(). */
   svn_error_t *(*get_inherited_props)(svn_ra_session_t *session,
                                       apr_array_header_t **iprops,
@@ -319,6 +326,17 @@ typedef struct svn_ra__vtable_t {
                                       svn_revnum_t revision,
                                       apr_pool_t *result_pool,
                                       apr_pool_t *scratch_pool);
+  /* If not NULL, receives a pointer to svn_ra_open, to alllow opening
+     a new ra session from inside the ra layer without a circular
+     library dependency*/
+  svn_error_t *(*set_svn_ra_open)(svn_ra_session_t *session,
+                                  svn_ra__open_func_t func);
+
+  /* Experimental support below here */
+
+  /* See svn_ra__register_editor_shim_callbacks() */
+  svn_error_t *(*register_editor_shim_callbacks)(svn_ra_session_t *session,
+                                                 svn_delta_shim_callbacks_t *callbacks);
   /* See svn_ra__get_commit_ev2()  */
   svn_error_t *(*get_commit_ev2)(
     svn_editor_t **editor,

Modified: subversion/branches/ra-git/subversion/libsvn_ra_local/ra_plugin.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_ra_local/ra_plugin.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_ra_local/ra_plugin.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_ra_local/ra_plugin.c Wed Dec  2 07:55:55 2015
@@ -1833,9 +1833,11 @@ static const svn_ra__vtable_t ra_local_v
   svn_ra_local__has_capability,
   svn_ra_local__replay_range,
   svn_ra_local__get_deleted_rev,
-  svn_ra_local__register_editor_shim_callbacks,
   svn_ra_local__get_inherited_props,
-  svn_ra_local__get_commit_ev2
+  NULL /* set_svn_ra_open */,
+  svn_ra_local__register_editor_shim_callbacks,
+  svn_ra_local__get_commit_ev2,
+  NULL /* replay_range_ev2 */
 };
 
 
@@ -1868,7 +1870,7 @@ svn_ra_local__init(const svn_version_t *
 
   SVN_ERR(svn_ver_check_list2(ra_local_version(), checklist, svn_ver_equal));
 
-#ifndef SVN_LIBSVN_CLIENT_LINKS_RA_LOCAL
+#ifndef SVN_LIBSVN_RA_LINKS_RA_LOCAL
   /* This means the library was loaded as a DSO, so use the DSO pool. */
   SVN_ERR(svn_fs_initialize(svn_dso__pool()));
 #endif

Modified: subversion/branches/ra-git/subversion/libsvn_ra_serf/serf.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_ra_serf/serf.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_ra_serf/serf.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_ra_serf/serf.c Wed Dec  2 07:55:55 2015
@@ -1050,8 +1050,11 @@ static const svn_ra__vtable_t serf_vtabl
   svn_ra_serf__has_capability,
   svn_ra_serf__replay_range,
   svn_ra_serf__get_deleted_rev,
+  svn_ra_serf__get_inherited_props,
+  NULL /* set_svn_ra_open */,
   svn_ra_serf__register_editor_shim_callbacks,
-  svn_ra_serf__get_inherited_props
+  NULL /* commit_ev2 */,
+  NULL /* replay_range_ev2 */
 };
 
 svn_error_t *

Modified: subversion/branches/ra-git/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_ra_svn/client.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_ra_svn/client.c Wed Dec  2 07:55:55 2015
@@ -2951,8 +2951,11 @@ static const svn_ra__vtable_t ra_svn_vta
   ra_svn_has_capability,
   ra_svn_replay_range,
   ra_svn_get_deleted_rev,
+  ra_svn_get_inherited_props,
+  NULL /* ra_set_svn_ra_open */,
   ra_svn_register_editor_shim_callbacks,
-  ra_svn_get_inherited_props
+  NULL /* commit_ev2 */,
+  NULL /* replay_range_ev2 */
 };
 
 svn_error_t *

Modified: subversion/branches/ra-git/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_ra_svn/marshal.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_ra_svn/marshal.c Wed Dec  2 07:55:55 2015
@@ -708,11 +708,15 @@ svn_ra_svn__write_ncstring(svn_ra_svn_co
                            const char *s,
                            apr_size_t len)
 {
-  apr_size_t needed = SVN_INT64_BUFFER_SIZE + len + 1;
+  /* Apart from LEN bytes of string contents, we need room for a number,
+     a colon and a space. */
+  apr_size_t max_fill = sizeof(conn->write_buf) - SVN_INT64_BUFFER_SIZE - 2;
 
   /* In most cases, there is enough left room in the WRITE_BUF
-     the we can serialize directly into it. */
-  if (conn->write_pos + needed < sizeof(conn->write_buf))
+     the we can serialize directly into it.  On platforms with
+     segmented memory, LEN might actually be close to APR_SIZE_MAX.
+     Blindly doing arithmetic on it might cause an overflow. */
+  if ((len <= max_fill) && (conn->write_pos <= max_fill - len))
     {
       /* Quick path. */
       conn->write_pos = write_ncstring_quick(conn->write_buf
@@ -960,20 +964,23 @@ write_tuple_string_opt_list(svn_ra_svn_c
                             apr_pool_t *pool,
                             const svn_string_t *str)
 {
-  apr_size_t needed;
+  apr_size_t max_fill;
 
   /* Special case. */
   if (!str)
     return writebuf_write(conn, pool, "( ) ", 4);
 
-  /* If there is at least this much the room left in the WRITE_BUF,
-     we can serialize directly into it. */
-  needed = 2                       /* open list */
-         + SVN_INT64_BUFFER_SIZE   /* string length + separator */
-         + str->len                /* string contents */
-         + 2;                      /* close list */
-
-  if (conn->write_pos + needed <= sizeof(conn->write_buf))
+  /* If this how far we can fill the WRITE_BUF with string data and still
+     guarantee that the length info will fit in as well. */
+  max_fill = sizeof(conn->write_buf)
+           - 2                       /* open list */
+           - SVN_INT64_BUFFER_SIZE   /* string length + separator */
+           - 2;                      /* close list */
+
+   /* On platforms with segmented memory, STR->LEN might actually be
+      close to APR_SIZE_MAX.  Blindly doing arithmetic on it might
+      cause an overflow. */
+  if ((str->len <= max_fill) && (conn->write_pos <= max_fill - str->len))
     {
       /* Quick path. */
       /* Open list. */
@@ -2808,20 +2815,26 @@ svn_ra_svn__write_data_log_changed_path(
   const svn_string_t *flags_str = changed_path_flags(node_kind,
                                                      text_modified,
                                                      props_modified);
+  apr_size_t flags_len = flags_str->len;
 
-  /* How much buffer space do we need (worst case)? */
-  apr_size_t needed = 2                 /* list start */
-                    + path_len + SVN_INT64_BUFFER_SIZE
-                                        /* path */
-                    + 2                 /* action */
-                    + 2 + copyfrom_len + 2 * SVN_INT64_BUFFER_SIZE
-                                        /* list start + copy-from info */
-                    + flags_str->len;   /* flags and closing lists */
+  /* How much buffer space can we use for non-string data (worst case)? */
+  apr_size_t max_fill = sizeof(conn->write_buf)
+                      - 2                          /* list start */
+                      - 2 - SVN_INT64_BUFFER_SIZE  /* path */
+                      - 2                          /* action */
+                      - 2                          /* list start */
+                      - 2 - SVN_INT64_BUFFER_SIZE  /* copy-from path */
+                      - 1 - SVN_INT64_BUFFER_SIZE; /* copy-from rev */
 
   /* If the remaining buffer is big enough and we've got all parts,
-     directly copy into the buffer. */
-  if (   (conn->write_pos + needed <= sizeof(conn->write_buf))
-      && (flags_str->len > 0))
+     directly copy into the buffer.   On platforms with segmented memory,
+     PATH_LEN + COPYFROM_LEN might actually be close to APR_SIZE_MAX.
+     Blindly doing arithmetic on them might cause an overflow.
+     The sum in here cannot overflow because WRITE_BUF is small, i.e.
+     MAX_FILL and WRITE_POS are much smaller than APR_SIZE_MAX. */
+  if (   (path_len <= max_fill) && (copyfrom_len <= max_fill)
+      && (conn->write_pos + path_len + copyfrom_len + flags_len <= max_fill)
+      && (flags_len > 0))
     {
       /* Quick path. */
       /* Open list. */

Modified: subversion/branches/ra-git/subversion/libsvn_subr/base64.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/base64.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/base64.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/base64.c Wed Dec  2 07:55:55 2015
@@ -141,7 +141,7 @@ encode_bytes(svn_stringbuf_t *str, const
   svn_stringbuf_ensure(str, str->len + buflen);
 
   /* Keep encoding three-byte groups until we run out.  */
-  while (*inbuflen + (end - p) >= 3)
+  while ((end - p) >= (3 - *inbuflen))
     {
       /* May we encode BYTES_PER_LINE bytes without caring about
          line breaks, data in the temporary INBUF or running out
@@ -430,7 +430,7 @@ decode_bytes(svn_stringbuf_t *str, const
       /* If no data is left in temporary INBUF and there is at least
          one line-sized chunk left to decode, we may use the optimized
          code path. */
-      if ((*inbuflen == 0) && (p + BASE64_LINELEN <= end))
+      if ((*inbuflen == 0) && (end - p >= BASE64_LINELEN))
         if (decode_line(str, &p))
           continue;
 

Modified: subversion/branches/ra-git/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/cache-membuffer.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/cache-membuffer.c Wed Dec  2 07:55:55 2015
@@ -1631,7 +1631,7 @@ ensure_data_insertable_l2(svn_membuffer_
   /* accumulated size of the entries that have been removed to make
    * room for the new one.
    */
-  apr_size_t moved_size = 0;
+  apr_uint64_t moved_size = 0;
 
   /* count the number of entries that got moved.  A single large entry
    * being moved is not enough to reject an insertion.
@@ -1673,7 +1673,7 @@ ensure_data_insertable_l2(svn_membuffer_
        * We must also limit the effort spent here (even in case of faulty
        * heuristics).  Therefore, give up after some time.
        */
-      if (moved_size > 4 * to_fit_in->size && moved_count > 7)
+      if (moved_size / 4 > to_fit_in->size && moved_count > 7)
         return FALSE;
 
       /* if the net worth (in weighted hits) of items removed is already
@@ -2214,14 +2214,29 @@ membuffer_cache_set_internal(svn_membuff
                              apr_pool_t *scratch_pool)
 {
   cache_level_t *level;
-  apr_size_t size = item_size + to_find->entry_key.key_len;
+  apr_size_t size;
 
   /* first, look for a previous entry for the given key */
   entry_t *entry = find_entry(cache, group_index, to_find, FALSE);
 
+  /* Quick size check to make sure arithmetics will work further down
+   * the road. */
+  if (   cache->max_entry_size >= item_size
+      && cache->max_entry_size - item_size >= to_find->entry_key.key_len)
+    {
+      size = item_size + to_find->entry_key.key_len;
+    }
+  else
+    {
+      /* The combination of serialized ITEM and KEY does not fit, so the
+       * the insertion attempt will fail and simply remove any old entry
+       * if that exists. */
+      buffer = NULL;
+    }
+
   /* if there is an old version of that entry and the new data fits into
    * the old spot, just re-use that space. */
-  if (entry && ALIGN_VALUE(entry->size) >= size && buffer)
+  if (entry && buffer && ALIGN_VALUE(entry->size) >= size)
     {
       /* Careful! We need to cast SIZE to the full width of CACHE->DATA_USED
        * lest we run into trouble with 32 bit underflow *not* treated as a

Modified: subversion/branches/ra-git/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/stream.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/stream.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/stream.c Wed Dec  2 07:55:55 2015
@@ -1513,7 +1513,7 @@ svn_stringbuf_from_stream(svn_stringbuf_
       if (actually_read < to_read)
         break;
 
-      if (text->blocksize < text->len + MIN_READ_SIZE)
+      if (text->blocksize - text->len < MIN_READ_SIZE)
         svn_stringbuf_ensure(text, text->blocksize * 2);
     }
 

Modified: subversion/branches/ra-git/subversion/libsvn_subr/string.c
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/libsvn_subr/string.c?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/libsvn_subr/string.c (original)
+++ subversion/branches/ra-git/subversion/libsvn_subr/string.c Wed Dec  2 07:55:55 2015
@@ -1421,7 +1421,7 @@ svn_cstring__match_length(const char *a,
    * because A and B will probably have different alignment. So, skipping
    * the first few chars until alignment is reached is not an option.
    */
-  for (; pos + sizeof(apr_size_t) <= max_len; pos += sizeof(apr_size_t))
+  for (; max_len - pos >= sizeof(apr_size_t); pos += sizeof(apr_size_t))
     if (*(const apr_size_t*)(a + pos) != *(const apr_size_t*)(b + pos))
       break;
 

Modified: subversion/branches/ra-git/subversion/svn_private_config.hw
URL: http://svn.apache.org/viewvc/subversion/branches/ra-git/subversion/svn_private_config.hw?rev=1717580&r1=1717579&r2=1717580&view=diff
==============================================================================
--- subversion/branches/ra-git/subversion/svn_private_config.hw (original)
+++ subversion/branches/ra-git/subversion/svn_private_config.hw Wed Dec  2 07:55:55 2015
@@ -61,10 +61,10 @@
 #define SVN_LIBSVN_FS_LINKS_FS_X
 
 /* Link local repos access library to client */
-#define SVN_LIBSVN_CLIENT_LINKS_RA_LOCAL
+#define SVN_LIBSVN_RA_LINKS_RA_LOCAL
 
 /* Link pipe repos access library to client */
-#define SVN_LIBSVN_CLIENT_LINKS_RA_SVN
+#define SVN_LIBSVN_RA_LINKS_RA_SVN
 
 /* Defined to be the path to the installed binaries */
 #define SVN_BINDIR "/usr/local/bin"



Mime
View raw message