Repository navigation
fix SimpleString equality for content with embedded NUL bytes - #1230
Merged
facontidavide merged 1 commit intoOct 10, 2026
Merged
Conversation
strncmp stops at the first NUL byte, so two different strings of equal length that agree up to an embedded NUL compared equal, while operator< ordered the same pair with memcmp. Embedded NUL bytes reach a blackboard string through ImportBlackboardFromJSON, where a JSON escape decodes to a real NUL, and the scripting == and != operators compare through SimpleString.
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.
On master, with the regression test from this branch:
s1ands2there are"a\0b"and"a\0c":operator==andoperator!=comparewith
strncmp, which stops at the first NUL byte, whileoperator<compares thefull length with
memcmp, so the same pair is reported both equal and ordered.Content with embedded NUL bytes is not hypothetical for
Any, sinceImportBlackboardFromJSONdecodes a JSON\u0000escape into a real NUL and thescripting
==/!=route throughSimpleString: restoring{"a":"p\u0000X","b":"p\u0000Y"}into a tree whose only node is<AlwaysFailure _skipIf="a == b"/>ticks to SKIPPED, so the guard skips a node overtwo values that are not equal. Switching the two operators to
memcmpis enough,and the size check in front of it keeps the read in bounds.
Full ctest is 526/526 on the macOS exclusion set, and the new test covers both the
in-place and the heap representation.