Skip to content

Commit 3d4b427

Browse files
de-nordickartben
authored andcommitted
storage/flash_map: Fix is_in_flash_area_bounds
Prevent possible overflow in is_in_flash_area_bounds while validating offset and length of an operation. Fixes #89349 Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
1 parent d608318 commit 3d4b427

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/storage/flash_map/flash_map_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static inline struct flash_area const *get_flash_area_from_id(int idx)
3333
static inline bool is_in_flash_area_bounds(const struct flash_area *fa,
3434
off_t off, size_t len)
3535
{
36-
return (off >= 0) && ((off + len) <= fa->fa_size);
36+
return (off >= 0) && (off < fa->fa_size) && (len <= (fa->fa_size - off));
3737
}
3838

3939
#endif /* ZEPHYR_SUBSYS_STORAGE_FLASH_MAP_PRIV_H_ */

0 commit comments

Comments
 (0)