substring_index may lead tiflash crash in some corner cases #9116
Labels
affects-5.3
affects-5.4
affects-6.1
affects-6.5
affects-7.1
affects-7.5
affects-8.1
component/compute
report/customer
Customers have encountered this bug.
severity/major
type/bug
The issue is confirmed as a bug.
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
For
substring_index(string, delim, count)
if the
string
containsn
delim
s, wheren >= 1 and n < count
, and thestring
end withdelim
, thentiflash/dbms/src/Functions/FunctionsString.cpp
Lines 5223 to 5233 in 9929b19
When finding the last match of
delim
,if (match == end || count == 0)
is false, sopos
is updated tomatch + delim_size
, since thestring
ends withdelim
,pos
is actually equal toend
, which makespos < end
false, and the function returns without callingcopyDataToResult
. This will make the result corrupt sincecopyDataToResult
is expected to be called for every input row.A simple reproduce is
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiFlash version? (Required)
The text was updated successfully, but these errors were encountered: