Repository navigation
Add bounds check in cbor_array_get() - #388
Merged
Merged
Conversation
The header documents returning NULL on out-of-bounds access, but the implementation had no check and would read arbitrary memory. Add the bounds check against end_ptr and return NULL when index is out of range. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PJK
force-pushed
the
fix-array-get-bounds-check
branch
from
February 8, 2026 17:17
2ed46ba to
02590db
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #388 +/- ##
===========================================
- Coverage 100.00% 99.87% -0.13%
===========================================
Files 20 20
Lines 1657 1659 +2
===========================================
Hits 1657 1657
- Misses 0 2 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
cbor_array_get()header documents returningNULLon boundary violation, but the implementation had no check and would perform an out-of-bounds readend_ptrand returnNULLwhen the index is out of rangeCBOR_ASSERT(cbor_isa_array(item))for consistency with other array functionsTest plan
test_array_get_out_of_boundscovering: valid index, index == size, index > size, and empty array🤖 Generated with Claude Code