Skip to content

[NOR]: "array out of bounds" error leading to memory corruption #58

Description

@rahmanih

Describe the bug

The loop below checks on the cache_size only, but accessing the nor_flash -> lx_nor_flash_extended_cache[i] array
incrementing the index without any check.

https://github.com/eclipse-threadx/levelx/blob/04e385f3d5586efdd5dffb1dd4c8ffa50317d70a/common/src/lx_nor_flash_extended_cache_enable.c#L293C4-L309C6

the fix is to change the while() condition as following
while((cache_size >= LX_NOR_SECTOR_SIZE) && i < LX_NOR_EXTENDED_CACHE_SIZE)

also replace the line

if(i > LX_NOR_EXTENDED_CACHE_SIZE)

with
if(i == LX_NOR_EXTENDED_CACHE_SIZE)

regards
haithem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions