Skip to content

Add unit test for null byte injected into a string token#30

Merged
ionux merged 1 commit intomainfrom
claude/add-null-byte-test-ZsvMa
Mar 11, 2026
Merged

Add unit test for null byte injected into a string token#30
ionux merged 1 commit intomainfrom
claude/add-null-byte-test-ZsvMa

Conversation

@ionux
Copy link
Copy Markdown
Owner

@ionux ionux commented Mar 11, 2026

Adds test_null_byte_in_string_value() which constructs the payload {"key": "val\0ue"} as an explicit char array (bypassing C string-literal truncation) and asserts that okj_parse() returns OKJ_ERROR_UNEXPECTED_END.

The parser's string-scan loop condition checks != '\0', so it exits as soon as the embedded null byte is reached — before the closing '"' is seen. The post-loop check then finds '\0' at the current position and returns OKJ_ERROR_UNEXPECTED_END, confirming that the null byte is caught rather than silently truncating the token.

https://claude.ai/code/session_01QE8StsdbAm8BWdKrb7PpxV

Adds test_null_byte_in_string_value() which constructs the payload
{"key": "val\0ue"} as an explicit char array (bypassing C string-literal
truncation) and asserts that okj_parse() returns OKJ_ERROR_UNEXPECTED_END.

The parser's string-scan loop condition checks != '\0', so it exits as
soon as the embedded null byte is reached — before the closing '"' is
seen.  The post-loop check then finds '\0' at the current position and
returns OKJ_ERROR_UNEXPECTED_END, confirming that the null byte is caught
rather than silently truncating the token.

https://claude.ai/code/session_01QE8StsdbAm8BWdKrb7PpxV
@ionux ionux merged commit f433c86 into main Mar 11, 2026
2 checks passed
@ionux ionux deleted the claude/add-null-byte-test-ZsvMa branch March 11, 2026 22:18
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