Verify hashes of source copy blocks at install time
In VABC, all copy ops are performed upfront without actually verifying
the hash. This CL adds the missing hash checks.
Test: th
Bug: 223471136
Change-Id: I1ec7ddee3122c9614484b2d8b7e9f38128428080
diff --git a/payload_consumer/vabc_partition_writer.cc b/payload_consumer/vabc_partition_writer.cc
index 9db88a9..583ba4c 100644
--- a/payload_consumer/vabc_partition_writer.cc
+++ b/payload_consumer/vabc_partition_writer.cc
@@ -33,6 +33,7 @@
#include "update_engine/payload_consumer/extent_map.h"
#include "update_engine/payload_consumer/extent_reader.h"
#include "update_engine/payload_consumer/file_descriptor.h"
+#include "update_engine/payload_consumer/file_descriptor_utils.h"
#include "update_engine/payload_consumer/install_plan.h"
#include "update_engine/payload_consumer/partition_writer.h"
#include "update_engine/payload_consumer/snapshot_extent_writer.h"
@@ -267,9 +268,13 @@
[[nodiscard]] bool VABCPartitionWriter::PerformSourceCopyOperation(
const InstallOperation& operation, ErrorCode* error) {
- // TODO(zhangkelvin) Probably just ignore SOURCE_COPY? They should be taken
- // care of during Init();
- return true;
+ // COPY ops are already handled during Init(), no need to do actual work, but
+ // we still want to verify that all blocks contain expected data.
+ auto source_fd = std::make_shared<EintrSafeFileDescriptor>();
+ TEST_AND_RETURN_FALSE_ERRNO(
+ source_fd->Open(install_part_.source_path.c_str(), O_RDONLY));
+ return PartitionWriter::ValidateSourceHash(
+ operation, source_fd, block_size_, error);
}
bool VABCPartitionWriter::PerformReplaceOperation(const InstallOperation& op,