[msm]: Check image size for emmc before write and align it to 512 bytes
- Check image size before writing images to emmc partitions.
- Round the image length to be 512 byte aligned.
Change-Id: I66f6273bfa2c6d36af58628794babd0430d2a88d
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 27e1196..fb2a216 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -442,6 +442,8 @@
void cmd_flash_mmc(const char *arg, void *data, unsigned sz)
{
unsigned long long ptn = 0;
+ unsigned long long size = 0;
+
ptn = mmc_ptn_offset(arg);
if(ptn == 0) {
fastboot_fail("partition table doesn't exist");
@@ -455,6 +457,12 @@
}
}
+ size = mmc_ptn_size(arg);
+ if (ROUND_TO_PAGE(sz,511) > size) {
+ fastboot_fail("size too large");
+ return;
+ }
+
if (mmc_write(ptn , sz, (unsigned int *)data)) {
fastboot_fail("flash write failure");
return;