storage/flash_map: Fix flash area bounds checking

The commit adds check if offset is positive; previously negative
offset would be allowed, which means that writing flash before flash
area start was possible.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
Dominik Ermel 2021-05-24 14:10:37 +00:00 committed by Kumar Gala
commit f20cc4b7a4

View file

@ -80,7 +80,7 @@ void flash_area_close(const struct flash_area *fa)
static inline bool is_in_flash_area_bounds(const struct flash_area *fa,
off_t off, size_t len)
{
return (off <= fa->fa_size && off + len <= fa->fa_size);
return (off >= 0) && ((off + len) <= fa->fa_size);
}
#if defined(CONFIG_FLASH_PAGE_LAYOUT)