Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ boot_scramble_region(const struct flash_area *fa, uint32_t off, uint32_t size, b
end_offset = ALIGN_DOWN((off + size), write_block);
}

while (true) {
while (off != end_offset) {
/* Write over the area to scramble data that is there */
rc = flash_area_write(fa, off, buf, write_block);
if (rc != 0) {
Expand All @@ -1291,12 +1291,12 @@ boot_scramble_region(const struct flash_area *fa, uint32_t off, uint32_t size, b

off -= write_block;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need changing also?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its backwards, so last chunk to be erase has off== end_offset.

} else {
if (end_offset < off) {
off += write_block;

if (end_offset <= off) {
/* Reached the end offset in range and already scrambled it */
break;
}

off += write_block;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions docs/release-notes.d/fix-boot-scramble-region.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Fixed issue in boot_scramble_regions, where incorrect boundary
check would cause function to attempt to write pass a designated
flash area.
Loading