From 171d19b6ee135bee4a263ea157ffac52cb0cbec8 Mon Sep 17 00:00:00 2001 From: John Bland Date: Tue, 15 Aug 2023 02:34:05 -0400 Subject: [PATCH] fix bad address copy if base is not the same as addr_read --- src/libwolfboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libwolfboot.c b/src/libwolfboot.c index d107ad853..b9b782d96 100644 --- a/src/libwolfboot.c +++ b/src/libwolfboot.c @@ -248,7 +248,7 @@ static int RAMFUNCTION partition_magic_write(uint8_t part, uintptr_t addr) nvm_cached_sector = nvm_select_fresh_sector(part); addr_read = base - (nvm_cached_sector * NVM_CACHE_SIZE); addr_write = base - (!nvm_cached_sector * NVM_CACHE_SIZE); - XMEMCPY(NVM_CACHE, (void*)base, NVM_CACHE_SIZE); + XMEMCPY(NVM_CACHE, (void*)addr_read, NVM_CACHE_SIZE); XMEMCPY(NVM_CACHE + off, &wolfboot_magic_trail, sizeof(uint32_t)); ret = hal_flash_write(addr_write, NVM_CACHE, WOLFBOOT_SECTOR_SIZE); nvm_cached_sector = !nvm_cached_sector;