summaryrefslogtreecommitdiff
path: root/verity
diff options
context:
space:
mode:
authorJinguang Dong <dongjinguang@huawei.com>2019-02-23 12:14:36 +0800
committerBowgo Tsai <bowgotsai@google.com>2019-02-23 07:07:13 +0000
commite6c8225bf30bb68c24fddba46538f42d78253c41 (patch)
treea226f3ebfc0985d3a71113cab6bfff0bd273e6b7 /verity
parent5e64dcd02e4c03f6bcd3d3cc65f4fc105191a31f (diff)
downloadextras-e6c8225bf30bb68c24fddba46538f42d78253c41.tar.gz
Fix build error of generating fec data
When we make the fec data for spare images, we will check each chunk the length of spare image but not the total length. If the libspare sends the data which is not a multiple of 4096, there is an error. We have reproduced it using our image. The data is send by https://android.googlesource.com/platform/system/core/+/fca4a9c27950a4a4281de0f413280cff9f4da653/libsparse/output_file.cpp#272 , and is checked by https://android.googlesource.com/platform/system/extras/+/29bf737e56e10c2742f1e14fe9f07184d59bbcc0/verity/fec/image.cpp#179 If the to_write in first link is equal INT_MAX, the assert in second link will be failed. Test: use fec to product fec data successfully ./fec --encode --roots 2 system.img fecdata Change-Id: Ib1e310a32bcda8acb3785d3784537d84fd439732
Diffstat (limited to 'verity')
-rw-r--r--verity/fec/image.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/verity/fec/image.cpp b/verity/fec/image.cpp
index 4b5502e4..43baeecd 100644
--- a/verity/fec/image.cpp
+++ b/verity/fec/image.cpp
@@ -80,7 +80,6 @@ static void calculate_rounds(uint64_t size, image *ctx)
static int process_chunk(void *priv, const void *data, size_t len)
{
image *ctx = (image *)priv;
- assert(len % FEC_BLOCKSIZE == 0);
if (data) {
memcpy(&ctx->input[ctx->pos], data, len);
@@ -136,6 +135,8 @@ static void file_image_load(const std::vector<int>& fds, image *ctx)
sparse_file_destroy(file);
}
+ assert(ctx->pos % FEC_BLOCKSIZE == 0);
+
for (auto fd : fds) {
close(fd);
}