Skip to content

Overflow check missing in _sbrk_r ? #16

@Pot8o-s

Description

@Pot8o-s

I am not sure about all the check that are being done by the newlib's _malloc_r implementation, but in your heap_useNewlib_ST.c file, isn't it safer to also add the following check in your _sbrk_r implementation to make sure we do not overflow the currentHeapEnd pointer:

    ....
    DRN_ENTER_CRITICAL_SECTION(usis);
    
    if (incr < 0 && currentHeapEnd + incr > currentHeapEnd ||
        incr > 0 && currentHeapEnd + incr < currentHeapEnd) {
        // Fail here because currentHeapEnd will be overflown.
    }
    
    if (currentHeapEnd + incr > limit) {
        ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions