Commit 52eee567 authored by David Brown's avatar David Brown Committed by David Brown
Browse files

Reload headers before verifying signature

After performing any kind of swap, reload the headers from the image(s)
before verifying the new image.
parent 554c52e6
Loading
Loading
Loading
Loading
+12
Changes for boot/bootutil/src/loader.c: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include <assert.h>
#include <stddef.h>
#include <stdbool.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
@@ -1225,6 +1226,7 @@ boot_go(struct boot_rsp *rsp)
    size_t slot;
    int rc;
    int fa_id;
    bool reload_headers = false;

    /* The array of slot sectors are defined here (as opposed to file scope) so
     * that they don't get allocated for non-boot-loader apps.  This is
@@ -1280,11 +1282,13 @@ boot_go(struct boot_rsp *rsp)
    case BOOT_SWAP_TYPE_PERM:
        slot = 1;
        boot_finalize_test_swap();
        reload_headers = true;
        break;

    case BOOT_SWAP_TYPE_REVERT:
        slot = 1;
        boot_finalize_revert_swap();
        reload_headers = true;
        break;

    case BOOT_SWAP_TYPE_FAIL:
@@ -1294,6 +1298,7 @@ boot_go(struct boot_rsp *rsp)
         */
        slot = 0;
        boot_finalize_revert_swap();
        reload_headers = true;
        break;

    default:
@@ -1303,6 +1308,13 @@ boot_go(struct boot_rsp *rsp)
    }

#ifdef MCUBOOT_VALIDATE_SLOT0
    if (reload_headers) {
            rc = boot_read_image_headers();
            if (rc != 0) {
                    goto out;
            }
    }

    rc = boot_validate_slot(0);
    assert(rc == 0);
    if (rc != 0) {