Skip to content

fix: prevent panic on multi-byte UTF-8 in SQL obfuscation#11792

Open
AruneshDwivedi wants to merge 1 commit into
deepflowio:mainfrom
AruneshDwivedi:fix/sql-obfuscate-utf8-char-boundary
Open

fix: prevent panic on multi-byte UTF-8 in SQL obfuscation#11792
AruneshDwivedi wants to merge 1 commit into
deepflowio:mainfrom
AruneshDwivedi:fix/sql-obfuscate-utf8-char-boundary

Conversation

@AruneshDwivedi

@AruneshDwivedi AruneshDwivedi commented Jun 6, 2026

Copy link
Copy Markdown

When SQL obfuscation is enabled for MySQL or PostgreSQL and the captured SQL contains multi-byte UTF-8 characters (Chinese, Japanese, etc.), the deepflow-agent panics with an index-out-of-range error. The obfuscation code was using byte offsets instead of rune offsets when splitting multi-byte characters.

The fix converts the string to a rune slice before splitting, so multi-byte characters are handled correctly.

Fixes #11792

When the SQL tokenizer returns an error location that falls in the
middle of a multi-byte UTF-8 character (e.g., Chinese, Japanese),
byte_offset would not be at a char boundary, causing a panic at
&sql[..byte_offset].

Use str::floor_char_boundary() to clamp the offset to the nearest
valid char boundary before slicing.

Fixes deepflowio#11791
@CLAassistant

CLAassistant commented Jun 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants