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 2017/02/04 18:44:43 UTC

svn commit: r1781694 - /subversion/trunk/subversion/libsvn_fs_fs/cached_data.c

Author: stefan2
Date: Sat Feb  4 18:44:43 2017
New Revision: 1781694

URL: http://svn.apache.org/viewvc?rev=1781694&view=rev
Log:
Fix a whole in FSFS's checksum usage.

If we feed a file content stream from the fulltext cache, FSFS won't
calculate a checksum over it because we already checked it when reading
it the first time.  However, if the file content does get evicted from
the cache while the stream has not been fullt read, yet, the remainder
must come from reconstructed text windows.  The current code did not
compare the checksum in this case - leaving it to the ra/client side
to detect intermediate corruptions.

This patch ensures we calculate the checksum over the full file content.
It then gets automatically verified once the last byte is being delivered.

Found by: julianfoad

* subversion/libsvn_fs_fs/cached_data.c
  (skip_contents): Run the checksum over the skipped part as well, so
                   that OFF will eventually match the fulltext length.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.c

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1781694&r1=1781693&r2=1781694&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Sat Feb  4 18:44:43 2017
@@ -2058,6 +2058,16 @@ skip_contents(struct rep_read_baton *bat
           len -= to_read;
           buffer += to_read;
         }
+
+      /* Make the MD5 calculation catch up with the data delivered
+       * (we did not run MD5 on the data that we took from the cache). */
+      if (!err)
+        {
+          SVN_ERR(svn_checksum_update(baton->md5_checksum_ctx,
+                                      baton->current_fulltext->data,
+                                      baton->current_fulltext->len));
+          baton->off += baton->current_fulltext->len;
+        }
     }
   else if (len > 0)
     {
@@ -2073,6 +2083,15 @@ skip_contents(struct rep_read_baton *bat
 
           err = get_contents_from_windows(baton, buffer, &to_read);
           len -= to_read;
+
+          /* Make the MD5 calculation catch up with the data delivered
+           * (we did not run MD5 on the data that we took from the cache). */
+          if (!err)
+            {
+              SVN_ERR(svn_checksum_update(baton->md5_checksum_ctx,
+                                          buffer, to_read));
+              baton->off += to_read;
+            }
         }
 
       svn_pool_destroy(subpool);