Merge "Fix potential size overflow in blockimg.cpp" am: 9a54dd3bf9 am: cc025b2b4a

am: d8063b0af4

Change-Id: I2c8fd5c1984f20157e8cbda07b476d0d6de458d7
This commit is contained in:
Tianjie Xu 2019-01-29 16:07:52 -08:00 committed by android-build-merger
commit 89b92c1217

View file

@ -1525,7 +1525,7 @@ static int PerformCommandComputeHashTree(CommandParameters& params) {
// Starts the hash_tree computation. // Starts the hash_tree computation.
HashTreeBuilder builder(BLOCKSIZE, hash_function); HashTreeBuilder builder(BLOCKSIZE, hash_function);
if (!builder.Initialize(source_ranges.blocks() * BLOCKSIZE, salt)) { if (!builder.Initialize(static_cast<int64_t>(source_ranges.blocks()) * BLOCKSIZE, salt)) {
LOG(ERROR) << "Failed to initialize hash tree computation, source " << source_ranges.ToString() LOG(ERROR) << "Failed to initialize hash tree computation, source " << source_ranges.ToString()
<< ", salt " << salt_hex; << ", salt " << salt_hex;
return -1; return -1;
@ -1915,8 +1915,10 @@ pbiudone:
const char* partition = strrchr(blockdev_filename->data.c_str(), '/'); const char* partition = strrchr(blockdev_filename->data.c_str(), '/');
if (partition != nullptr && *(partition + 1) != 0) { if (partition != nullptr && *(partition + 1) != 0) {
fprintf(cmd_pipe, "log bytes_written_%s: %zu\n", partition + 1, params.written * BLOCKSIZE); fprintf(cmd_pipe, "log bytes_written_%s: %" PRIu64 "\n", partition + 1,
fprintf(cmd_pipe, "log bytes_stashed_%s: %zu\n", partition + 1, params.stashed * BLOCKSIZE); static_cast<uint64_t>(params.written) * BLOCKSIZE);
fprintf(cmd_pipe, "log bytes_stashed_%s: %" PRIu64 "\n", partition + 1,
static_cast<uint64_t>(params.stashed) * BLOCKSIZE);
fflush(cmd_pipe); fflush(cmd_pipe);
} }
// Delete stash only after successfully completing the update, as it may contain blocks needed // Delete stash only after successfully completing the update, as it may contain blocks needed