mirror of https://github.com/wolfSSL/wolfBoot.git
hal_flash_write() in hal/hifive1.c selected the page path and clamped the partial-page length from the original total len instead of the bytes still remaining (len - j). A page-aligned multi-page write that ended in a partial page therefore took the full-page branch on the last iteration: it read past the end of the caller's buffer and programmed a full 256-byte page where only the remaining bytes were requested, clobbering flash past the update range. Compute remaining = len - j at the top of the loop and use it for both the branch test and the rel_len clamp; j still advances only by the bytes actually consumed (256 on the full-page path, rel_len on the partial path). unit-hifive1-flash-write runs the real extracted function against a mock fespi model (FLASH_BASE points at a flash image buffer, fespi_write_address/fespi_sw_tx program into it, and the RMW path reads the image back through FLASH_BASE as on hardware). The regression case is a 356-byte aligned write: the last page's tail must stay erased, which fails pre-fix (the over-read bytes are programmed instead). Verification: - Built: riscv-none-elf-gcc 15.2 -fsyntax-only -Wall with ARCH_RISCV: clean. - Tested: unit-hifive1-flash-write 3/3; pre-fix the 356-byte case wrote non-erased bytes past offset 356 of the flash image. Unaligned single-page RMW and exact-full-page cases unchanged. - Pitfalls: relative (sub-FLASH_BASE) addresses are accepted as-is by the function, which is what the test passes so the 32-bit address parameter never carries a 64-bit host pointer. - Style: cstyle-check.sh flag count on hal/hifive1.c unchanged from the pre-change file; the new test trips only the uncrustify pointer-alignment class the sibling unit tests trip. - Message: F-11035: prefix, no co-author trailers. - Unverified: no HiFive1 board execution. |
||
|---|---|---|
| .. | ||
| armclang | ||
| bin-assemble | ||
| check_config | ||
| ci | ||
| delta | ||
| efi | ||
| elf-parser | ||
| fdt-parser | ||
| keytools | ||
| lms | ||
| openocd | ||
| renode | ||
| sbom | ||
| scripts | ||
| squashelf | ||
| test-expect-version | ||
| test-update-server | ||
| tpm | ||
| uart-flash-server | ||
| unit-tests | ||
| xmss | ||
| config.mk | ||
| test-delta.mk | ||
| test-enc.mk | ||
| test-renode.mk | ||
| test.mk | ||
| wolfboot-rpi-devicetree.diff | ||