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 2013/06/29 21:52:24 UTC

svn commit: r1498006 - /subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c

Author: stefan2
Date: Sat Jun 29 19:10:47 2013
New Revision: 1498006

URL: http://svn.apache.org/r1498006
Log:
On the fsfs-format7 branch:  Make the p2l index lookup robust against
requests with out-of-bound offsets.

* subversion/libsvn_fs_fs/index.c
  (p2l_page_info_copy): check for out-of-bounds; return well-defined result

Modified:
    subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c

Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c?rev=1498006&r1=1498005&r2=1498006&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/index.c Sat Jun 29 19:10:47 2013
@@ -1899,13 +1899,27 @@ p2l_page_info_copy(p2l_page_info_baton_t
                    const p2l_header_t *header,
                    const apr_off_t *offsets)
 {
-  baton->page_no = baton->offset / header->page_size;
+  /* if the requested offset is out of bounds, return info for 
+   * a zero-sized empty page right behind the last page.
+   */
+  if (baton->offset / header->page_size < header->page_count)
+    {
+      baton->page_no = baton->offset / header->page_size;
+      baton->start_offset = offsets[baton->page_no];
+      baton->next_offset = offsets[baton->page_no + 1];
+      baton->page_size = header->page_size;
+    }
+  else
+    {
+      baton->page_no = header->page_count;
+      baton->start_offset = offsets[baton->page_no];
+      baton->next_offset = offsets[baton->page_no];
+      baton->page_size = 0;
+    }
+
   baton->first_revision = header->first_revision;
-  baton->start_offset = offsets[baton->page_no];
-  baton->next_offset = offsets[baton->page_no + 1];
   baton->page_start = (apr_off_t)(header->page_size * baton->page_no);
   baton->page_count = header->page_count;
-  baton->page_size = header->page_size;
 }
 
 /* Implement svn_cache__partial_getter_func_t: extract the p2l page info