This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

fds pages_init can write beyond end of m_pages array

Using SDK 12.1.0 with flash containing data from a previous version of software.

The pages_init function in fds.c does no have adequate protection to prevent writing to data beyond the end of the m_pages array. The pages index variable can be come equal to FDS_MAX_PAGES which in my case causes a buffer overrun on the swtich (page_type) case FDS_PAGE_DATA when it writes to the m_pages[page].page_type and .p_addr and .write_offset.

Please fix the initialization so that it is safe for unexpected data as this may occur in the real world with bugs that cause memory corruption or software updates may find the flash in an unexpected state.

Find attached the contents of the flash that caused the bug to be exposed. flash_memory_contents.txt

Related