rustyconover opened a new pull request, #971:
URL: https://github.com/apache/arrow-nanoarrow/pull/971
Closes #970.
`ArrowIpcEncodeMetadata()` wrote `KeyValue` keys 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 Message
`custom_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 exactly `size_bytes` bytes. The
decoder already reads keys and values by length. No other IPC encoder code uses
`_create_strn()`.
The new `NanoarrowIpcEncoderMetadataWithNulBytes` test round-trips schema,
field and message metadata whose keys and values contain NUL bytes, through the
encoder/decoder and through `ArrowIpcWriter`/`ArrowIpcArrayStreamReader`, and
checks that the bytes match exactly. It fails without the fix: `("field\0key",
"\0field\0value")` decoded as `("field", "")`. `ctest` passes 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](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]