From ae4768cc6fd916cf4471ad4d3db125549e895a33 Mon Sep 17 00:00:00 2001 From: zhangran <911830982@qq.com> Date: Thu, 22 Apr 2021 17:51:45 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E8=AF=BB?= =?UTF-8?q?=E5=86=99=E6=8E=A5=E5=8F=A3=E6=BA=A2=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fal_partition.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fal_partition.c b/src/fal_partition.c index 9aee41e..0d7abcd 100644 --- a/src/fal_partition.c +++ b/src/fal_partition.c @@ -411,7 +411,7 @@ int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t assert(part); assert(buf); - if (addr + size > part->len) + if (addr >= part->len || part->len - addr < size) { log_e("Partition read error! Partition address out of bound."); return -1; @@ -452,7 +452,7 @@ int fal_partition_write(const struct fal_partition *part, uint32_t addr, const u assert(part); assert(buf); - if (addr + size > part->len) + if (addr >= part->len || part->len - addr < size) { log_e("Partition write error! Partition address out of bound."); return -1; @@ -491,7 +491,7 @@ int fal_partition_erase(const struct fal_partition *part, uint32_t addr, size_t assert(part); - if (addr + size > part->len) + if (addr >= part->len || part->len - addr < size) { log_e("Partition erase error! Partition address out of bound."); return -1;