summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJi Luo <ji.luo@nxp.com>2020-10-28 09:12:59 +0800
committerJi Luo <ji.luo@nxp.com>2022-04-18 16:40:09 +0800
commit574f122979311296ad4ca6c5f2cc822970d4ca57 (patch)
tree0e3875a5d1a73d8a4be23071a5f6e49b198a0523 /lib
parent725135dc99499d9383af58956ee91f2f7a4b4179 (diff)
MA-18166 Android: Fix mmc multi blk load issue
The 'offset' can be negative number passed from fsl_read_from_partition_multi(), don't covert 'blksz' to 'uint64_t' as it will cause overflow when the 'offset' is negative number. Test: mmc blk read with 'offset < 0'. Signed-off-by: Ji Luo <ji.luo@nxp.com> Change-Id: Id1ce8e0c748dd280d70c1722cc7d17cc9646a4bb (cherry picked from commit 077b448679b9ad2891495c7344ba99a6c10a59fb) (cherry picked from commit f927599650ba1fbdbe8f4887b970a4f003b0d277) (cherry picked from commit 9533092f7557e2f728d5fc59836ceac19658291d)
Diffstat (limited to 'lib')
-rw-r--r--lib/avb/fsl/utils.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/avb/fsl/utils.c b/lib/avb/fsl/utils.c
index 3e70d576c8..e44cc8a9f2 100644
--- a/lib/avb/fsl/utils.c
+++ b/lib/avb/fsl/utils.c
@@ -26,9 +26,9 @@ int get_margin_pos(uint64_t part_start, uint64_t part_end, unsigned long blksz,
return -1;
if (offset < 0) {
- margin->blk_start = (offset + 1) / (uint64_t)blksz + part_end;
+ margin->blk_start = (offset + 1) / (int64_t)blksz + part_end;
// offset == -1 means the last byte?, or start need -1
- margin->start = (off = offset % (uint64_t)blksz) == 0 ?
+ margin->start = (off = offset % (int64_t)blksz) == 0 ?
0 : blksz + off;
if (offset + num_bytes - 1 >= 0) {
if (!allow_partial)
@@ -38,9 +38,9 @@ int get_margin_pos(uint64_t part_start, uint64_t part_end, unsigned long blksz,
} else {
// which blk the last byte is in
margin->blk_end = (num_bytes + offset) /
- (uint64_t)blksz + part_end;
+ (int64_t)blksz + part_end;
margin->end = (off = (num_bytes + offset - 1) %
- (uint64_t)blksz) == 0 ?
+ (int64_t)blksz) == 0 ?
0 : blksz + off; // last byte
}
} else {