mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-07-21 14:19:04 -04:00
fw: Limit flash offsets to be within sane limits
Limit flash offsets passed to syscalls. Be sure to check the limits before doing any form of calculation with the passed values. Co-authored-by: Mikael Ågren <mikael@tillitis.se>
This commit is contained in:
parent
506b4c8269
commit
632b6d8fc7
2 changed files with 30 additions and 2 deletions
|
@ -67,7 +67,15 @@ int preload_store(struct partition_table *part_table, uint32_t offset,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((offset + size) > SIZE_PRE_LOADED_APP || size > 4096) {
|
||||
if (offset > SIZE_PRE_LOADED_APP) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (size > 4096) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if ((offset + size) > SIZE_PRE_LOADED_APP) {
|
||||
/* Writing outside of area */
|
||||
return -2;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue