You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++][Gandiva] Out-of-bounds read in translate on truncated multi-byte input #50462
Describe the bug, including details regarding any error messages, version, and platform.
translate_utf8_utf8_utf8 (cpp/src/gandiva/gdv_string_function_stubs.cc) has a multi-byte code path that runs whenever any of the input, FROM, or TO strings contains a byte > 127. That path reads gdv_fn_utf8_char_length on a lead byte and then builds a std::string of that many bytes without checking how many bytes are left in the buffer.
Three reads can go past the end:
a truncated trailing multi-byte glyph in the input (e.g. a lone 0xF0) reads up to 3 bytes past the input;
a multi-byte input character that is not present in FROM reads one byte past FROM at the end-of-list sentinel (the from_for == from_len check happens after the read);
a truncated glyph in TO reads past TO.
All three are reachable from the SQL translate(in, from, to) function on adversarial or simply truncated column data.
Minimal ASAN reproduction of the input over-read (faithful extraction of the multi-byte branch):
char* in = new char[1];
in[0] = (char)0xF0; // claims a 4-byte glyph, only 1 byte present
translate_utf8_utf8_utf8(ctx, in, 1, "a", 1, "b", 1, &out_len);
// AddressSanitizer: heap-buffer-overflow READ of size 4, 0 bytes after 1-byte region
Activity
apacheGH-50462: [C++][Gandiva] add regression test for truncated TO g…
GH-50462: [C++][Gandiva] fix out-of-bounds read in translate_utf8_utf…
kou commentedon Jul 16, 2026
Issue resolved by pull request 50463
#50463