aboot: Add error check while flashing sparse image
Add error check to make sure the size of partition is greater
than the size of image being flashed.
Change-Id: I812a83d3d5206e74a0c708f439bc138f92523580
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index fabccb1..e2a6174 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -912,6 +912,7 @@
chunk_header_t *chunk_header;
uint32_t total_blocks = 0;
unsigned long long ptn = 0;
+ unsigned long long size = 0;
int index = INVALID_PTN;
index = partition_get_index(arg);
@@ -921,6 +922,12 @@
return;
}
+ size = partition_get_size(index);
+ if (ROUND_TO_PAGE(sz,511) > size) {
+ fastboot_fail("size too large");
+ return;
+ }
+
/* Read and skip over sparse image header */
sparse_header = (sparse_header_t *) data;
data += sparse_header->file_hdr_sz;