fix(oracle): guard SUBSTRB end boundary - #1848
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe multibyte ChangesSUBSTRB multibyte boundary handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change prevents SUBSTRB from inspecting beyond a multibyte input boundary and adds coverage for an exact UTF-8 byte boundary. The implementation and regression expectation align, with no remaining merge-blocking risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thank you for this patch! We'll review it shortly. |
|
Built this on aarch64 Linux (master + patch) and ran the full Two observations from the same session, both "sharing data, not asking for
Looks like when the start position lands mid-character, the (Reference for the Oracle side: the SUBSTR family in the 23ai SQL Language |
|
Thanks for the detailed verification. I agree that the ordinary result is unchanged: once the scan pointer reaches the end, any positive |
Summary
SUBSTRBfrom callingpg_mblen()after its scan pointer reaches the end of the varlena payloadWhy
When the requested byte range ends exactly at the source boundary, the loop advances
subStrEndto the one-past-end pointer. The old loop condition then evaluatespg_mblen(subStrEnd)before determining that another character cannot fit. Because a multibyte character length is always positive, this usually does not change the returned value; the defect is the out-of-bounds read itself, which depends on the adjacent memory layout and is not reliably observable in a normal result assertion.The added regression case exercises this boundary and protects the expected result. Detecting the old read directly requires an instrumented memory-safety build.
Testing
git diff --checkoracle-checksuite passing 28/28 withENCODING=UTF8Closes #1844
Assisted-by: OpenAI:GPT-5
Percentage of AI-generated code: 100%