mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-05-03 06:35:03 -04:00
fw: Only allow sector aligned erase ops
This commit is contained in:
parent
930d204e9f
commit
fba6e04c7f
1 changed files with 6 additions and 1 deletions
|
@ -142,13 +142,18 @@ int storage_erase_sector(struct partition_table *part_table, uint32_t offset,
|
|||
return -3;
|
||||
}
|
||||
|
||||
/* Cannot only erase entire sectors */
|
||||
if (offset % 4096 != 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Cannot erase less than one sector */
|
||||
if (size < 4096 || size > SIZE_STORAGE_AREA ||
|
||||
size % 4096 != 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if ((offset) >= SIZE_STORAGE_AREA) {
|
||||
if ((offset + size) >= SIZE_STORAGE_AREA) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue