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/05/20 08:59:24 UTC

svn commit: r1680460 - in /subversion/trunk/subversion/libsvn_fs_fs: low_level.c low_level.h rev_file.c

Author: stefan2
Date: Wed May 20 06:59:24 2015
New Revision: 1680460

URL: http://svn.apache.org/r1680460
Log:
fsfs7: Validate index offsets in rev file footer.

* subversion/libsvn_fs_fs/low_level.c
  (svn_fs_fs__parse_footer): Take FILESIZE argument, use it for validation.

* subversion/libsvn_fs_fs/low_level.h
  (svn_fs_fs__parse_footer): Take FILESIZE argument.

* subversion/libsvn_fs_fs/rev_file.c
  (svn_fs_fs__auto_read_footer): Pass FILESIZE.

Patch by: danielsh

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/low_level.c
    subversion/trunk/subversion/libsvn_fs_fs/low_level.h
    subversion/trunk/subversion/libsvn_fs_fs/rev_file.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/low_level.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/low_level.c?rev=1680460&r1=1680459&r2=1680460&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/low_level.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/low_level.c Wed May 20 06:59:24 2015
@@ -196,6 +196,7 @@ svn_fs_fs__parse_footer(apr_off_t *l2p_o
                         svn_checksum_t **p2l_checksum,
                         svn_stringbuf_t *footer,
                         svn_revnum_t rev,
+                        svn_filesize_t filesize,
                         apr_pool_t *result_pool)
 {
   apr_int64_t val;
@@ -207,7 +208,8 @@ svn_fs_fs__parse_footer(apr_off_t *l2p_o
     return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                             _("Invalid revision footer"));
 
-  SVN_ERR(svn_cstring_atoi64(&val, str));
+  SVN_ERR_W(svn_cstring_strtoi64(&val, str, 0, filesize - 1, 10),
+            "Invalid L2P offset in revision footer");
   *l2p_offset = (apr_off_t)val;
 
   /* Get the L2P checksum. */
@@ -225,7 +227,8 @@ svn_fs_fs__parse_footer(apr_off_t *l2p_o
     return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
                             _("Invalid revision footer"));
 
-  SVN_ERR(svn_cstring_atoi64(&val, str));
+  SVN_ERR_W(svn_cstring_strtoi64(&val, str, 0, filesize - 1, 10),
+            "Invalid P2L offset in revision footer");
   *p2l_offset = (apr_off_t)val;
 
   /* Get the P2L checksum. */

Modified: subversion/trunk/subversion/libsvn_fs_fs/low_level.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/low_level.h?rev=1680460&r1=1680459&r2=1680460&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/low_level.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/low_level.h Wed May 20 06:59:24 2015
@@ -67,6 +67,8 @@ svn_fs_fs__unparse_revision_trailer(apr_
  * *P2L_OFFSET, respectively.  Also, return the expected checksums in
  * in *L2P_CHECKSUM and *P2L_CHECKSUM.
  *
+ * FILESIZE is used for validation.
+ *
  * Note that REV is only used to construct nicer error objects that
  * mention this revision.  Allocate the checksums in RESULT_POOL.
  */
@@ -77,6 +79,7 @@ svn_fs_fs__parse_footer(apr_off_t *l2p_o
                         svn_checksum_t **p2l_checksum,
                         svn_stringbuf_t *footer,
                         svn_revnum_t rev,
+                        svn_filesize_t filesize,
                         apr_pool_t *result_pool);
 
 /* Given the offset of the L2P index data in L2P_OFFSET, the content

Modified: subversion/trunk/subversion/libsvn_fs_fs/rev_file.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/rev_file.c?rev=1680460&r1=1680459&r2=1680460&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/rev_file.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/rev_file.c Wed May 20 06:59:24 2015
@@ -259,6 +259,7 @@ svn_fs_fs__auto_read_footer(svn_fs_fs__r
       SVN_ERR(svn_fs_fs__parse_footer(&file->l2p_offset, &file->l2p_checksum,
                                       &file->p2l_offset, &file->p2l_checksum,
                                       footer, file->start_revision,
+                                      filesize,
                                       file->pool));
       file->footer_offset = filesize - footer_length - 1;
     }