Fix bugs and improve robustness in example code#407
Merged
Conversation
The default macOS resource class changed to m4pro.medium, which requires an explicit resource_class in the config. Also bump Xcode from 16.0.0 to 16.4.0 (latest stable supported on m4pro). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix arithmetic bugs in CBOR negint handling (cbor2cjson.c, cjson2cbor.c), prevent infinite loop on decode errors (streaming_parser.c), remove fixed-size key buffer with silent truncation (cbor2cjson.c), and add missing return value checks for fread/sscanf across all examples. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #407 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 1663 1663
=========================================
Hits 1663 1663 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
cbor2cjson.c: unsigned arithmetic oncbor_get_int()(returnsuint64_t) caused wraparound; usedoublearithmetic insteadcjson2cbor.c:valueint + 1produced wrong value for thenegint64callback; use(uint64_t)(-1 - valueint)per CBOR encoding rulesstreaming_parser.c: ifcbor_stream_decodereturnsCBOR_DECODER_ERROR,.readis 0 causing an infinite loop; add error check withbreakcbor2cjson.c: replace fixed 128-byte buffer with silent truncation with dynamic allocation based on actual key lengthcbor_movepattern incbor2cjson.cwith explicit get/use/decref for clarityfread/sscanfreturn value checks across all 6 example filescjson2cbor.c: replace unprofessional/unclear commentsTest plan
cmake --buildwith-DWITH_EXAMPLES=ONsucceedsclang-format.shpasses🤖 Generated with Claude Code