Repository navigation
fix(ipc): Don't truncate metadata keys and values at NUL bytes - #971
Open
rustyconover wants to merge 1 commit into
Open
rustyconover wants to merge 1 commit into
rustyconover wants to merge 1 commit into
Conversation
ArrowIpcEncodeMetadata() wrote KeyValue keys and values with flatcc's _create_strn(), which stops at the first NUL byte (it uses strnlen()). Metadata keys and values are length-prefixed in both ArrowSchema and the flatbuffer, and NUL is valid UTF-8, so a key or value containing a NUL byte was silently truncated in Schema, Field and Message custom_metadata. Use the length-exact _create() so exactly size_bytes bytes are written. The decoder already read them length-exactly. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #971 +/- ##
=======================================
Coverage 78.24% 78.24%
=======================================
Files 106 106
Lines 16901 16901
Branches 2012 2012
=======================================
Hits 13224 13224
Misses 2435 2435
Partials 1242 1242 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Closes #970.
ArrowIpcEncodeMetadata()wroteKeyValuekeys and values with flatcc's_create_strn(). That function stops at the first NUL byte (flatcc_builder_create_string(B, s, strnlen(s, max_len))), so a metadata key or value containing a NUL was silently truncated in Schema, Field and Messagecustom_metadata. NUL (U+0000) is valid UTF-8, and both nanoarrow's metadata format and flatbuffers strings store a length with each string, so the encoder now uses the length-exact_create()to write exactlysize_bytesbytes. The decoder already reads keys and values by length. No other IPC encoder code uses_create_strn().The new
NanoarrowIpcEncoderMetadataWithNulBytestest round-trips schema, field and message metadata whose keys and values contain NUL bytes, through the encoder/decoder and throughArrowIpcWriter/ArrowIpcArrayStreamReader, and checks that the bytes match exactly. It fails without the fix:("field\0key", "\0field\0value")decoded as("field", "").ctestpasses with and without Arrow C++, also under ASan/UBSan, and pre-commit passes on the changed files.This PR's code and description were written by AI (Claude Code) and reviewed by a human maintainer.
🤖 Generated with Claude Code