Commit c6a7b0c7 authored by Fabio Utzig's avatar Fabio Utzig Committed by David Brown
Browse files

Fixes use of invalid header data

Fixes a bug when MCUBOOT_VALIDATE_SLOT0 is enabled which caused the
header in Slot 1 to be used for calculating the bootstrap offset. This
bug is masked when MCUBOOT_OVERWRITE_ONLY is not enabled because both
slots have the same header size (usually!). With MCUBOOT_OVERWRITE_ONLY
Slot 1 was erased and the header size would be read as 0xffff resulting
in a jump to the wrong address.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent 8d0e5884
Loading
Loading
Loading
Loading
+6
Changes for boot/bootutil/src/loader.c: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1343,6 +1343,12 @@ boot_go(struct boot_rsp *rsp)
        if (rc != 0) {
            goto out;
        }
        /* Since headers were reloaded, it can be assumed we just performed a
         * swap or overwrite. Now the header info that should be used to
         * provide the data for the bootstrap, which previously was at Slot 1,
         * was updated to Slot 0.
         */
        slot = 0;
    }

    rc = boot_validate_slot(0);