sys/clif: Fixing out of bounds read under certain conditions [backport 2022.10] #18810
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #18744
Hi 😈
This fixes a potential out of bounds read in
clif_encode_link
. There is no code in RIOT that can be exploited & and the close bymemcpy
only operates within a safe/length checked buffer.The fix does not break the current API.
I also added a new test which also acts as an example on how to use clif.
Run
make -C tests/unittests tests-clif
andmake -C tests/unittests term
to test the fix.Side note: I did not run uncrustify as this would have filled this PR with a lot of unrelated changes. Somebody should open a separate PR for those cosmetic changes.
cc @leandrolanzieri