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

[Feature request]: Add buffer length checks #9

Closed
stijnb1234 opened this issue Aug 9, 2024 · 3 comments · Fixed by #12
Closed

[Feature request]: Add buffer length checks #9

stijnb1234 opened this issue Aug 9, 2024 · 3 comments · Fixed by #12
Assignees
Labels
bug Something isn't working

Comments

@stijnb1234
Copy link

stijnb1234 commented Aug 9, 2024

Background and motivation

I've had the situation that I got weird errors because I tried to write text longer than the buffer can hold. There is no check for buffer length < write length.

Describe the solution expected

Add a check if CONFIG_NEX_UART_TRANS_COMMAND_FORMAT_BUFFER_SIZE is smaller then the amount of bytes to write, then return specific error.

Additional info

No response

@gfurtadoalmeida gfurtadoalmeida added the enhancement New feature or request label Aug 9, 2024
@gfurtadoalmeida gfurtadoalmeida self-assigned this Jan 16, 2025
@gfurtadoalmeida
Copy link
Owner

gfurtadoalmeida commented Feb 20, 2025

Hi @stijnb1234 ,
Thinking about the implementation, as the buffer cannot be resized at runtime, having an error code of a condition that cannot be recovered might not help.
What is your opinion about using abort?

@gfurtadoalmeida gfurtadoalmeida added bug Something isn't working and removed enhancement New feature or request labels Feb 20, 2025
@stijnb1234
Copy link
Author

An error code at least gives me insight about what happend. Most of the time, text is fixed.

@gfurtadoalmeida
Copy link
Owner

Hi @stijnb1234, would you be interested in testing the code in the buffer-length-check branch?
Functions will return NEX_FAIL if an instruction cannot be formatted, with the current buffer size and required size being logged.

Be aware that this branch might have braking changes depending on what functions you are using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants