You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/11/07 12:47:04 UTC
svn commit: r1713111 - in /subversion/trunk/subversion:
include/svn_error_codes.h libsvn_fs_x/revprops.c
Author: stefan2
Date: Sat Nov 7 11:47:04 2015
New Revision: 1713111
URL: http://svn.apache.org/viewvc?rev=1713111&view=rev
Log:
Add some consistency checks to FSX' packed revprop manifest parser.
* subversion/include/svn_error_codes.h
(SVN_ERR_FS_CORRUPT_REVPROP_MANIFEST): Define new error code.
* subversion/libsvn_fs_x/revprops.c
(get_revprop_packname): Verify that the entries are in proper order
and within the shard's revision range.
Modified:
subversion/trunk/subversion/include/svn_error_codes.h
subversion/trunk/subversion/libsvn_fs_x/revprops.c
Modified: subversion/trunk/subversion/include/svn_error_codes.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_error_codes.h?rev=1713111&r1=1713110&r2=1713111&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_error_codes.h (original)
+++ subversion/trunk/subversion/include/svn_error_codes.h Sat Nov 7 11:47:04 2015
@@ -868,6 +868,11 @@ SVN_ERROR_START
SVN_ERR_FS_CATEGORY_START + 63,
"Invalid generation number data.")
+ /** @since New in 1.10. */
+ SVN_ERRDEF(SVN_ERR_FS_CORRUPT_REVPROP_MANIFEST,
+ SVN_ERR_FS_CATEGORY_START + 64,
+ "Revprop manifest corrupt.")
+
/* repos errors */
SVN_ERRDEF(SVN_ERR_REPOS_LOCKED,
Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.c?rev=1713111&r1=1713110&r2=1713111&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.c Sat Nov 7 11:47:04 2015
@@ -608,12 +608,18 @@ get_revprop_packname(svn_fs_t *fs,
const char *manifest_file_path;
svn_stream_t *stream;
int idx;
+ svn_revnum_t previous_start_rev;
+ int i;
/* Determine the dimensions. Rev 0 is excluded from the first shard. */
+ int rev_count = ffd->max_files_per_dir;
svn_revnum_t manifest_start
- = revprops->revision - (revprops->revision % ffd->max_files_per_dir);
+ = revprops->revision - (revprops->revision % rev_count);
if (manifest_start == 0)
- ++manifest_start;
+ {
+ ++manifest_start;
+ --rev_count;
+ }
/* Read the content of the manifest file */
revprops->folder = svn_fs_x__path_pack_shard(fs, revprops->revision,
@@ -626,6 +632,32 @@ get_revprop_packname(svn_fs_t *fs,
SVN_ERR(read_manifest(&revprops->manifest, stream, result_pool,
scratch_pool));
+ /* Verify the manifest data. */
+ if (revprops->manifest->nelts == 0)
+ return svn_error_createf(SVN_ERR_FS_CORRUPT_REVPROP_MANIFEST, NULL,
+ "Revprop manifest for r%ld is empty",
+ revprops->revision);
+
+ previous_start_rev = 0;
+ for (i = 0; i < revprops->manifest->nelts; ++i)
+ {
+ svn_revnum_t start_rev = APR_ARRAY_IDX(revprops->manifest, i,
+ manifest_entry_t).start_rev;
+ if ( start_rev < manifest_start
+ || start_rev >= manifest_start + rev_count)
+ return svn_error_createf(SVN_ERR_FS_CORRUPT_REVPROP_MANIFEST, NULL,
+ "Revprop manifest for r%ld contains "
+ "out-of-range revision r%ld",
+ revprops->revision, start_rev);
+
+ if (start_rev < previous_start_rev)
+ return svn_error_createf(SVN_ERR_FS_CORRUPT_REVPROP_MANIFEST, NULL,
+ "Entries in revprop manifest for r%ld "
+ "are not ordered", revprops->revision);
+
+ previous_start_rev = start_rev;
+ }
+
/* Now get the pack file description */
idx = get_entry(revprops->manifest, revprops->revision);
revprops->entry = APR_ARRAY_IDX(revprops->manifest, idx,