[fix](be) Remove unsafe JsonbWriter key overload#63355
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
5c39e10 to
3cbbf65
Compare
|
/review |
There was a problem hiding this comment.
Review result: no blocking issues found in the PR patch.
Critical checkpoint conclusions:
- Goal/test: The PR removes the unsafe JsonbWriter::writeKey(const char*) overload and updates existing tests to use explicit lengths; the changed tests cover the affected call sites in JSONB unit tests.
- Scope: The change is small and focused on the overload removal plus required test updates.
- Concurrency/lifecycle/config/compatibility: Not applicable; no runtime concurrency, lifecycle, config, storage format, or protocol changes are introduced.
- Parallel code paths: Existing C++ call sites either already pass explicit lengths/key ids or are updated in tests; no remaining single-argument char* use was found in the reviewed patch.
- Error handling/memory/data correctness: No new Status handling or memory ownership paths are introduced. The explicit-length API preserves embedded NUL bytes that the removed strlen overload could truncate.
- Tests: Relevant BE unit tests are updated; I did not rerun them in this review-only pass.
- Observability/performance: Not applicable; this is compile-time API hardening.
User focus: no additional user-provided review focus was present.
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 31274 ms |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-DS: Total hot run time: 169646 ms |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
| } | ||
|
|
||
| bool writeKey(const char* key) { return writeKey(key, strlen(key)); } | ||
| bool writeKey(const char* key) = delete; |
### What problem does this PR solve?
Issue Number: N/A
Related PR: N/A
Problem Summary: JsonbWriter::writeKey(const char*) used strlen to infer the key length, which made callers vulnerable to silent truncation when passing data with embedded NUL bytes. Remove the overload so callers must use the explicit-length API.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- ./run-be-ut.sh --run --filter=JsonbDocumentTest.*:JsonbSerializeTest.*:JsonbParserTest.*:ConvertFieldToTypeTest.*
- build-support/clang-format.sh
- build-support/check-format.sh
- build-support/run-clang-tidy.sh --build-dir be/ut_build_ASAN (failed: existing clang-tidy environment/pre-existing diagnostics report missing stddef.h and unmatched NOLINTEND in be/src/core/types.h)
- Behavior changed: Yes. Internal C++ callers can no longer use JsonbWriter::writeKey(const char*) and must pass an explicit key length.
- Does this need documentation: No
3cbbf65 to
1b8c30c
Compare
|
/review |
|
run buildall |
TPC-H: Total hot run time: 31532 ms |
TPC-DS: Total hot run time: 170478 ms |
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
Problem Summary: `JsonbWriter::writeKey(const char*)` inferred key
length with `strlen`, which silently truncated byte strings that
contained embedded NUL bytes. Remove this overload so callers must use
the explicit-length API.
### Release note
None
### Check List (For Author)
- Test: Unit Test
- `./run-be-ut.sh --run
--filter=JsonbDocumentTest.*:JsonbSerializeTest.*:JsonbParserTest.*:ConvertFieldToTypeTest.*`
- `build-support/clang-format.sh`
- `build-support/check-format.sh`
- `build-support/run-clang-tidy.sh --build-dir be/ut_build_ASAN`
(failed: existing clang-tidy environment/pre-existing diagnostics report
missing `stddef.h` and unmatched `NOLINTEND` in `be/src/core/types.h`)
- Behavior changed: Yes. Internal C++ callers can no longer use
`JsonbWriter::writeKey(const char*)` and must pass an explicit key
length.
- Does this need documentation: No
What problem does this PR solve?
Related PR: N/A
Problem Summary:
JsonbWriter::writeKey(const char*)inferred key length withstrlen, which silently truncated byte strings that contained embedded NUL bytes. Remove this overload so callers must use the explicit-length API.Release note
None
Check List (For Author)
./run-be-ut.sh --run --filter=JsonbDocumentTest.*:JsonbSerializeTest.*:JsonbParserTest.*:ConvertFieldToTypeTest.*build-support/clang-format.shbuild-support/check-format.shbuild-support/run-clang-tidy.sh --build-dir be/ut_build_ASAN(failed: existing clang-tidy environment/pre-existing diagnostics report missingstddef.hand unmatchedNOLINTENDinbe/src/core/types.h)JsonbWriter::writeKey(const char*)and must pass an explicit key length.