Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
martinw32 opened this issue Nov 18, 2021 · 0 comments
Open

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

martinw32 opened this issue Nov 18, 2021 · 0 comments
Milestone

Comments

@martinw32
Copy link

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.

@XVilka XVilka added this to the 0.4 milestone Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants