Skip to content

Commit 2a6c79b

Browse files
committed
Fix rp2 avmpack scan bound to end of flash
The XIP_SRAM_BASE bound spans past the flash, so a corrupt section size could steer bounded header reads into unmapped address space. Signed-off-by: Davide Bettio <davide@uninstall.it>
1 parent fb24392 commit 2a6c79b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/platforms/rp2/src/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ static int app_main()
8585
const char *startup_module_name;
8686

8787
uint32_t main_avm_size = 0;
88-
if (!avmpack_compute_size(
89-
MAIN_AVM, (uint32_t) (XIP_SRAM_BASE - (uintptr_t) MAIN_AVM), &main_avm_size)) {
88+
if (!avmpack_compute_size(MAIN_AVM,
89+
(uint32_t) (XIP_BASE + PICO_FLASH_SIZE_BYTES - (uintptr_t) MAIN_AVM),
90+
&main_avm_size)) {
9091
sleep_ms(5000);
9192
fprintf(stderr, "main.avm is missing or truncated. Please flash your application.\n");
9293
if (avmpack_is_valid(LIB_AVM, (uintptr_t) MAIN_AVM - (uintptr_t) LIB_AVM)) {

0 commit comments

Comments
 (0)