-
Notifications
You must be signed in to change notification settings - Fork 1
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
Set correct buffer size in into_options() on libcoap<4.3.5rc2 #31
Conversation
Workflow Status ReportGenerated for commit 722fddc on Fri Aug 23 12:44:20 UTC 2024. Linting ReportClippy check result: success Refer to the "Files Changed" tab for identified issues. Code Coverage Report
Diff against main
Results for commit: 906e151 Coverage target is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work finding and solving the issue here :) See a couple of small suggestions below, other than that: Looks good to me :)
60d69f2
to
6504603
Compare
f32f6f0
to
906e151
Compare
Versions of libcoap older than 4.3.5rc2 used a user-provided buffer for temporarily storing the options during conversion.
This buffer, however, must be larger than what the libcoap documentation originally suggested, as this buffer area must also hold the option headers.
If this is not done, trailing elements of the URI are silently removed.
This PR increases the used buffer size for this temporary buffer to a value that should be large enough to store all options that could be created from this URI.
Additionally, it adds a check for newer libcoap versions that don't use this buffer anymore.
In that case, we just pass an empty buffer instead, saving memory and avoiding some iterations over the URI path and query string to determine the buffer size.