Skip to content

fix: validate string lengths before allocation and body reads - #27

Merged
jinzhongjia merged 2 commits into
mainfrom
fix/validate-string-length-before-allocation
Sep 14, 2026
Merged

jinzhongjia merged 2 commits into
mainfrom
fix/validate-string-length-before-allocation

Conversation

@jinzhongjia

@jinzhongjia jinzhongjia commented Sep 14, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Oversized strings are now rejected consistently across all supported string formats before payload data is read or memory is allocated.
    • String-length limit handling now provides consistent StringTooLong errors.
  • Documentation

    • Updated Zig compatibility guidance to include Zig 0.15.x and earlier through library version 0.0.17.
    • Clarified when oversized string validation occurs during decoding.

@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 413d3207-7eaa-4c2f-b6b9-07da8284a957

📥 Commits

Reviewing files that changed from the base of the PR and between 4891e43 and 913afd1.

📒 Files selected for processing (4)
  • README.md
  • README_CN.md
  • src/msgpack.zig
  • src/test.zig

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The decoder centralizes string-length validation for fixstr, str8, str16, and str32 values. Tests verify rejection before allocation and payload reads. English and Chinese documentation update Zig compatibility information and parsing behavior.

String length validation

Layer / File(s) Summary
Pre-read string validation and coverage
src/msgpack.zig, src/test.zig
String decoding validates declared lengths before allocation or payload reads. Tests cover all string formats and allocation failures.
Compatibility and parsing documentation
README.md, README_CN.md
Documentation updates Zig version mappings and describes StringTooLong behavior after consuming only the marker and length prefix.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: burakssen

Merge Risk: ⚪ Minimal · up to 913af

The string-length validation change is covered for all string encodings before allocation and payload reads, with no unresolved merge risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: validating string lengths before allocation and body reads.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/validate-string-length-before-allocation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jinzhongjia
jinzhongjia merged commit 6d9ef09 into main Sep 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant