diff --git a/src/libwolfboot.c b/src/libwolfboot.c index 99db6ee9..6e877e3b 100644 --- a/src/libwolfboot.c +++ b/src/libwolfboot.c @@ -1401,6 +1401,7 @@ int wolfBoot_dualboot_candidate(void) if (fallback_v < candidate_v) { wolfBoot_printf("Rollback to lower version not allowed\n"); + wolfBoot_erase_partition(candidate); return -1; } #endif diff --git a/src/update_flash_hwswap.c b/src/update_flash_hwswap.c index 8548fbfd..d2c4900b 100644 --- a/src/update_flash_hwswap.c +++ b/src/update_flash_hwswap.c @@ -62,6 +62,7 @@ void RAMFUNCTION wolfBoot_start(void) if ((max_v > 0U) && (active_v < max_v)) { wolfBoot_printf("Rollback to lower version not allowed\n"); boot_panic(); + continue; } #endif if ((wolfBoot_open_image(&fw_image, active) < 0) diff --git a/tools/unit-tests/unit-update-ram-nofixed.c b/tools/unit-tests/unit-update-ram-nofixed.c index 1b936a98..52efec6d 100644 --- a/tools/unit-tests/unit-update-ram-nofixed.c +++ b/tools/unit-tests/unit-update-ram-nofixed.c @@ -210,6 +210,7 @@ START_TEST(test_invalid_update_rollback_to_older_boot_is_denied) ck_assert_int_eq(wolfBoot_staged_ok, 0); ck_assert_int_eq(wolfBoot_panicked, 1); + ck_assert_ptr_eq((void *)wolfBoot_stage_address, (void *)0xFFFFFFFF); cleanup_flash(); } END_TEST diff --git a/tools/unit-tests/unit-update-ram.c b/tools/unit-tests/unit-update-ram.c index 2837629f..4c94bbc7 100644 --- a/tools/unit-tests/unit-update-ram.c +++ b/tools/unit-tests/unit-update-ram.c @@ -380,6 +380,7 @@ START_TEST (test_invalid_update_type) { wolfBoot_start(); ck_assert(!wolfBoot_staged_ok); ck_assert_int_eq(wolfBoot_panicked, 1); + ck_assert_int_eq(get_version_ramloaded(), 2); cleanup_flash(); }