From commits-return-46546-apmail-subversion-commits-archive=subversion.apache.org@subversion.apache.org Sat Feb 4 18:44:45 2017 Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A7C7719984 for ; Sat, 4 Feb 2017 18:44:45 +0000 (UTC) Received: (qmail 80627 invoked by uid 500); 4 Feb 2017 18:44:45 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 80585 invoked by uid 500); 4 Feb 2017 18:44:45 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 80575 invoked by uid 99); 4 Feb 2017 18:44:45 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Feb 2017 18:44:45 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id AE4833A108E for ; Sat, 4 Feb 2017 18:44:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1781694 - /subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Date: Sat, 04 Feb 2017 18:44:43 -0000 To: commits@subversion.apache.org From: stefan2@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170204184443.AE4833A108E@svn01-us-west.apache.org> 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);