Skip to content

packed header is not 32 bit aligned->can cause memory fault #50

@martinw32

Description

@martinw32

In the function capn_write_mem_packed in capn-malloc.c the uint32_t pointer "header" is calculated.
The function gets a 32 bit aligend pointer to the payload buffer passed.
"header" has an offset to the payload buffer pointer of header size + 2 bytes. Depending on header size it can happen that "header" is not aligned to 32 bit.
Subsequently header_render() performs 32 bit write access to the unaligned "header" pointer.

Processor which can't perform unaligned 32 bit access went to hard fault/memory fault.

As a walk around it is possible to write the data to be written in a variable and copy the variable to the pointer with memcpy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions