Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Accessing a returned null pointer #15

@thcu-gp

Description

@thcu-gp

oc_endpoint_t *endpoint = oc_memb_alloc(&oc_endpoints_s);

And potentially other places that involve oc_memb_alloc.

Description:
If OC_DYNAMIC_ALLOCATION is disabled, oc_memb_alloc returns a pointer to a part of a statically allocated structure buffer with compile-time defined size. It returns NULL if no more space is available in the buffer. The return value is not checked for validity.
Since we never know how many endpoints will be present in an incoming packet, it is possible to overflow the buffer, causing the code to try to access a NULL pointer.

Proposal:
Add NULL-checks and graceful handle a returned NULL pointer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions