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

Memory corruptions when casting enum to int * #233

Open
maribu opened this issue Jan 11, 2022 · 1 comment
Open

Memory corruptions when casting enum to int * #233

maribu opened this issue Jan 11, 2022 · 1 comment
Labels
fix added A fix has been added, but not yet in a release
Milestone

Comments

@maribu
Copy link

maribu commented Jan 11, 2022

RIOT-OS is packaging this repo downstream. I just opened a PR to fix a memory corruption bug downstream that still seems to be present here.

The issue is relatively trivial: The C standard doesn't say which size an enum has, only that it needs to be large enough to hold all constants defined in that enum. So sizeof(enum QoS) == sizeof(int) - as assumed in this library - is not generally correct. Casting a pointer to enum QoS to int * and passing this to a function that accesses this int * could e.g. result in a 32 bit memory access of an 8 bit value.

This issue might be something you want to fix soonish.

@icraggs
Copy link
Contributor

icraggs commented Aug 1, 2023

Thank you. This was fixed in commit: e233d99 albeit in a slightly different way.

@icraggs icraggs added the fix added A fix has been added, but not yet in a release label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix added A fix has been added, but not yet in a release
Projects
None yet
Development

No branches or pull requests

2 participants