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

fluf: fix UB in get_option_from_buff #75

Open
wants to merge 1 commit into
base: anjay4
Choose a base branch
from

Conversation

JungerBoyo
Copy link

@JungerBoyo JungerBoyo commented Nov 23, 2024

Make temp_payload_len local of type uint16_t instead of size_t to pass a ptr to update_extended_option without causing undefined behaviour.

Function update_extended_option dereferences passed uint16_t ptr which in this case is pointing to size_t type.

When built with Arm GNU Toolchain 13.2.rel1 with flags:

-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Os -Wall

compiled code is incorrect which leads to opt->payload_len not being properly updated which subsequently leads to wrong if condition result which causes FLUF_ERR_BUFF error later on.

Signed-off-by: Piotr Zalewski [email protected]

Make temp_payload_len local of type uint16_t instead of size_t to
pass a ptr to update_extended_option without causing undefined behaviour.

Function update_extended_option dereferences passed uint16_t ptr which
in this case is pointing to size_t type.

When built with Arm GNU Toolchain 13.2.rel1 with flags:
```
-mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -Os -Wall
```
compiled code is incorrect which leads to `opt->payload_len` not being
properly updated which subsequently leads to wrong if condition result
which causes FLUF_ERR_BUFF error later on.
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

Successfully merging this pull request may close these issues.

1 participant