Commit a0065f8f authored by Dominik Ermel's avatar Dominik Ermel Committed by Andrzej Puzdrowski
Browse files

bootutil: Fix boot_scramble_region escaping flash area



Incorrect range check fix.

Signed-off-by: default avatarDominik Ermel <dominik.ermel@nordicsemi.no>
parent bb644c7c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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) {
@@ -1291,12 +1291,12 @@ boot_scramble_region(const struct flash_area *fa, uint32_t off, uint32_t size, b

                off -= write_block;
            } 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;
            }
        }
    }
+3 −0
Original line number Diff line number Diff line
 - Fixed issue in boot_scramble_regions, where incorrect boundary
   check would cause function to attempt to write pass a designated
   flash area.