Description[Content verification] Fix a bug for files that are multiple of 4k bytes.
There was an off-by-one error in ContentVerifyJob::FinishBlock, that
would try to look beyond the last 4k block if the total file size was
multiple of 4k block. The out of bound block would not be returned
by hash_reader_->GetHashForBlock, so content verification would always
fail. e.g.
For an 8k file:
FinishBlock() -> for bytes 0-4095
FinishBlock() -> for bytes 4096-8191
Then an additional FinishBlock() from either ContentVerifyJob::DoneReading or
ContentVerifyJob::OnHashesReady would get called.
Ideally we shouldn't be calling the third FinishBlock() in this case, but
because how the code is laid out currently:
1) hash fetching and reading file content to compute hashes in any order, and
2) handling zero byte and deleted files,
It is less intrusive to add a bail out in FinishBlock to handle this case.
The bug was exposed by https://codereview.chromium.org/2771953003.
This CL also adds regression tests.
BUG=720597
Test=See bug description for reproduction.
Review-Url: https://codereview.chromium.org/2928693002
Cr-Commit-Position: refs/heads/master@{#477751}
Committed: https://chromium.googlesource.com/chromium/src/+/2557ca6ae520912f73ff133c4371a45a2cb43161
Patch Set 1 #
Total comments: 4
Patch Set 2 : address comments #
Messages
Total messages: 20 (13 generated)
|