Browse Source

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>
pull/35650/head
Dominik Ermel 4 years ago committed by Kumar Gala
parent
commit
f20cc4b7a4
  1. 2
      subsys/storage/flash_map/flash_map.c

2
subsys/storage/flash_map/flash_map.c

@ -80,7 +80,7 @@ void flash_area_close(const struct flash_area *fa) @@ -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)

Loading…
Cancel
Save