Skip to content

Add OKJ_MAX_JSON_LEN constant and enforce it in okj_parse()#10

Merged
ionux merged 1 commit intomainfrom
claude/add-json-length-constant-JdSUi
Mar 5, 2026
Merged

Add OKJ_MAX_JSON_LEN constant and enforce it in okj_parse()#10
ionux merged 1 commit intomainfrom
claude/add-json-length-constant-JdSUi

Conversation

@ionux
Copy link
Copy Markdown
Owner

@ionux ionux commented Mar 5, 2026

Introduces a new compile-time constant OKJ_MAX_JSON_LEN (4096 bytes) in ok_json.h that caps the maximum raw JSON input length, consistent with the existing per-string, array, and object size limits. okj_parse() now measures the input length before tokenisation begins and returns the new error code OKJ_ERROR_MAX_JSON_LEN_EXCEEDED (17) if the limit is breached, preventing the parser from walking arbitrarily long buffers on safety-critical targets.

https://claude.ai/code/session_011ivTN6vQfZ3n4uNJao9SEx

Introduces a new compile-time constant OKJ_MAX_JSON_LEN (4096 bytes) in
ok_json.h that caps the maximum raw JSON input length, consistent with the
existing per-string, array, and object size limits.  okj_parse() now measures
the input length before tokenisation begins and returns the new error code
OKJ_ERROR_MAX_JSON_LEN_EXCEEDED (17) if the limit is breached, preventing the
parser from walking arbitrarily long buffers on safety-critical targets.

https://claude.ai/code/session_011ivTN6vQfZ3n4uNJao9SEx
@ionux ionux merged commit 4d230fa into main Mar 5, 2026
2 checks passed
@ionux ionux deleted the claude/add-json-length-constant-JdSUi branch March 5, 2026 21:02
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.

2 participants